NET-A-PORTER/scala-uri

It's not possible to prevent percent encoding of non-ascii letters

Closed this issue · 1 comments

scala> implicit val config = UriConfig(encoder = percentEncode -- 'ø')
config: com.netaporter.uri.config.UriConfig = UriConfig(PercentEncoder(Set(*, %, }, ], =, <, &, !, \, |, `, ),  , ", @, ,, ;, ', [, #, {, ?, +, (, :, $, ^, /, >)),PercentEncoder(Set(*, %, }, ], =, <, &, !, \, |, `, ),  , ", @, ,, ;, ', [, #, {, ?, +, (, :, $, ^, /, >)),PercentEncoder(Set(*, %, }, ], =, <, &, !, \, |, `, ),  , ", @, ,, ;, ', [, #, {, ?, +, (, :, $, ^, /, >)),com.netaporter.uri.decoding.PercentDecoder$@37071e3f,com.netaporter.uri.decoding.PercentDecoder$@37071e3f,com.netaporter.uri.decoding.PercentDecoder$@37071e3f,false,UTF-8)

scala> Uri.parse("http://sub.dom.com/search?q=høl")
res20: com.netaporter.uri.Uri = http://sub.dom.com/search?q=h%C3%B8l

This is of-course a result of def ascii(ch: Char) = ch > 31 && ch < 127. Maybe a whitelist would be better way to manipulate the set "charsToEncode"? I guess the drawback is a slight increase in complexity.
And I realize that this would break with the URI spec, but so will many of the other possible exclusions.

As I need this functionality to create IRI's I'll just write a scala-Uri to IRI converter for the time being, but since the flexibility of custom percent encoding is there, why not go all the way?

I'm closing this one. After going through this in my head I've come to realize that URI and IRI are two different things, and should be handled separately. And that's pretty much the end of it I think.