NET-A-PORTER / scala-uri

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

URIs the do not have '//' after 'scheme:' #115

Closed evanbennett closed 7 years ago

evanbennett commented 8 years ago

The 'mailto' (and 'urn', 'news', etc.) schemes do not have the double forward slash after the colon.

I was looking for a library to better parse URIs and found a reference to this project.

I noticed that:

mention the 'mailto' scheme, and have been integrating the library into my project, but ran into an issue.

A valid mailto 'mailto:user@host' parses with the entire URI as a 'path' (incidentally with a prefixed '/').

I thought about inserting the "//" after the colon to parse as the 'scheme', 'user' and 'host', but another valid mailto is ''mailto:user1@host1,user2@host2' which parses with 'host,user2@host' as the 'host'.

Questions:

If yes: The RFC specifies that URIs without a '//' have everything after the 'scheme:' and before '?query' as the path. (RFC section 3. Syntax Components)

theon commented 8 years ago

Good spot. Those mailto URIs look wrong...

I would like scala-uri to support URIs that do not have '//', but currently it does not.

I would prefer scala-uri not to enforce too many of the restrictions in the RFC as there are a lot of technically invalid URIs out there on the Internet. I'd rather that the parsing was permissive and allowed users to parse these URIs.