URI.js
                                
                                
                                
                                    URI.js copied to clipboard
                            
                            
                            
                        Parsing of non urn-urn like URIs
Hey there. First off: Greate Library, saved us a ton of work.
I just found a small inconsistency/naming issue:
URI.parse('mailto:[email protected]')
/* returns
{
	path: "[email protected]",
	protocol: "mailto",
	urn: true,
}
*/
(Executable in the browser here)
I understand that in URI.js everything that is an not an url (aka missing the authority) is marked as an urn, which is not quite right, as the urn spec defines, that a urn starts with urn:.
My proposal would be that internally instead of urn, url would be used:
URI.parse('mailto:[email protected]')
/* returns
{ url: false, ... }
*/
URI.parse('http://google.com')
URI.parse('/relative/path')
/* returns
{ url: true, ... }
*/
                                    
                                    
                                    
                                
RFC3986 section 1.1.3: The term "Uniform Resource Name" (URN) has been used historically to refer to both URIs under the "urn" scheme RFC2141, which are required to remain globally unique and persistent even when the resource ceases to exist or becomes unavailable, and to any other URI with the properties of a name.
As far as I can tell URI.js does not deal with URNs as specified by RFC2141. Within URI.js the term URN is used in the second sense of the definition: »… to any other URI with the properties of a name«.
I can see how this is confusing. What exactly are you trying to achieve that you need the flag urn: true be renamed to url: false?
Ha, thanks for that section.
I just thought it would make more sense in a for API consistency. And to
The docs state, that
.is("urn") // true if URI looks like a URN
and I really like the wording "like a URN".
Maybe just rename it to urnLike or if you prefer not changing the API, simply adding a few sentences to the docs would be enough.
Would you like a merge requests with a few docs improvements? As far as I see, the docs mention "URN" only two times in the API documentation. Especially ".parse" and ".segments" may be missing examples.
Would you like a merge requests with a few docs improvements?
you know I do ;)