NET-A-PORTER / scala-uri

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

Parsing URI without scheme gives a path instead of (expected) host #95

Closed brujoand closed 9 years ago

brujoand commented 9 years ago
scala> parse("www.test.com")
res14: com.netaporter.uri.Uri = /www.test.com

if the parser finds a string containing only [a-zA-Z0-9] and dot. Wouldn't it be a better guess to set this as the host and not append it as a path on a hostless uri?

theon commented 9 years ago

I'm not sure. [a-zA-Z0-9] and dot can be a valid relative path too. E.g. "index.html"

brujoand commented 9 years ago

hm, yeah that's a good point. I guess it's one of those things where you just have to make a choice and stick with it. In this case Path vs Host, and as path is already chosen it would make sense to stick with that. I would have chosen host in this case because an absolute url has more valid use cases than a relative url, but I agree that it's not really an obvious choice. Feel free to close.