NET-A-PORTER / scala-uri

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

Having / and ? next to each other isn't possible #111

Closed bjfletcher closed 8 years ago

bjfletcher commented 8 years ago

Hi there,

Thanks for a really good library. :-)

I have this URL:

/search/?page=1

which can't be:

/search?page=1

I've tried to represent that using your library:

/ "search" / ? ("page" -> "1")

But it seems that having / and ? next to each other isn't possible (compile-time error: cannot resolve symbol /).

A workaround I'm using is a bit ugly:

/ "search/" ? ("page" -> "1")

I'm wondering if you know of a nicer/better workaround? Perhaps a new /? operator?

Thanks, once again, for this library. Makes our life so easy!

bjfletcher commented 8 years ago

A better workaround:

/ "search" / "" ? ("page" -> "1")

Not bad...

theon commented 8 years ago

Thanks for the request and posting the work arounds!

I have published a new version 0.4.14 with a/?` method in the DSL, so you can now make URLs like so, if you wish:

/ "search" /? ("page" -> "1")

Having a space between the / and ? would be quite difficult to do, so I compromised. Let me know what you think.