NET-A-PORTER/scala-uri

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

Closed this issue · 2 comments

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

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

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.