Would it make more sense to use a dedicated library for URL manipulation, like [URI.js](http://medialize.github.io/URI.js/)?