This really belongs in our url module: https://github.com/guardian/frontend/blob/master/common/app/assets/javascripts/modules/url.js