I submitted a PR that addresses most of the issues brought up here by implementing what @DavidEGrayson suggested.
https://github.com/discourse/discourse/pull/4645
It’s not completely perfect because it doesn’t work URLs that are prefixed by existing Ember.js routes, but those can continue to be handled by the special case infrastructure introduced by @eviltrout here
https://meta.discourse.org/t/left-clicking-raw-links-return-404-errors/31314/15?u=ryantm