NET-A-PORTER / scala-uri

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

Domain names are preprended with '/' #107

Open juliendangers opened 8 years ago

juliendangers commented 8 years ago

Is it normal that urls without protocol (actually domain names) are preprended with '/' ?

I added the following test

"domain name" should "be parsed correctly" in {
  val uri = parse("mydomain.com")
  uri.toString should equal("mydomain.com")
}

and uri.toString = "/mydomain.com"

theon commented 8 years ago

Hi @juliendangers,

scala-uri currently parses this as a path rather than a host, because it is a valid path. Example: https://who.is/whois/mydomain.com - this page could have a <a href="mydomain.com"> and browsers treat that as a path, not a host. For it to be treated as a host, you need to prepend with a scheme.

This all said, /path and path are different URIs, so it is a bug that the slash is prepended :)