Closed mansilladev closed 4 years ago
Perhaps line 686 was meant to be:
if (parts.path.charAt(0) !== '/' && typeof parts.hostname === 'string' && requireAbsolutePath)
you're seeing the result of #387
because your url atlassian.com
is missing a protocol, it's not parsed as a hostname, but a relative path.
var url = new URI("atlassian.com");
console.log(JSON.stringify(url._parts, null, 2))
outputs
{
"protocol": null,
"username": null,
"password": null,
"hostname": null,
"urn": null,
"port": null,
"path": "atlassian.com",
"query": null,
"fragment": null,
"preventInvalidHostname": false,
"duplicateQueryParameters": false,
"escapeQuerySpace": true
}
Maybe it's time to revisit #260 (and the unfinished attempt at providing a solution: #374) and provide a proper API for what you're trying to do… Are you looking to get your hands dirty with this?
Given that we consistently have just a raw hostname (no proto/scheme/port), perhaps it’s best to start with a blank object, and fill in the parts, eh?
Our library/app (atlassian-connect-express) has been using it the way I described for years, and with recent urijs updates, we started getting reports of the triple slash.
I’ll take a look at #374 and see how dirty I’d like to get my hands. But for the short term, I believe we’ve got a fix. Thanks for your help today, and for your continued support on this library.
https://github.com/medialize/URI.js/commit/4ced30a1c5ad278eae70bb06dee8d7886e68052b
The commit above (handle relative paths) on version 1.19.2 causes an extra slash to be added.
Output is:
https:///atlassian.com