So it turns out URIjs is a pretty handy library. The [absoluteTo](http://medialize.github.io/URI.js/docs.html#absoluteto) method does exactly what we want, so I figured it would be a good idea to keep the code path as unified as possible.