NET-A-PORTER / scala-uri

Simple scala library for building and parsing URIs
Other
261 stars 33 forks source link

Characters after '#' is encoded even if part of valid URL #99

Closed hjz closed 8 years ago

hjz commented 9 years ago

AngularJS's routing system creates URLs of the scheme /#/<:page:>, e.g:

https://www.foo.com/#/myPage?token=bar

This gets encoded into:

https://www.foo.com/#%2FmyPage-%3Ftoken%bar

Which breaks the routing.

JustAHappyKid commented 9 years ago

I think this is effectively the same issue as I described in #97 (though I only pointed out the unnecessary escaping of =).

bfalese-despegar commented 9 years ago

I'm experiencing this issue too

hjz commented 8 years ago

Google groups uses has a similar issue

https://groups.google.com/forum/#!forum/elasticsearch

theon commented 8 years ago

Sorry for the delay. This should be fixed in 0.4.11 so that only the # character gets percent encoded by default in the fragment.

You should be able to also get the desired result on older versions by bringing an custom implicit UriConfig into scope where you render the URL, like so:

implicit val config = UriConfig.default.copy(fragmentEncoder = PercentEncoder(`#`))