This needs a test. Move to `app/scripts/lib/url`.