Closed seshness closed 5 years ago
I'm inclined to call this a bug. I'd say https://github.com/medialize/URI.js/blob/gh-pages/src/URI.js#L684 should be changed to
if (parts.path.charAt(0) !== '/' && t) {
thanks for reporting this! It's fixed and released as 1.19.2
Hi @rodneyrehm
Do you really think this is a valid change? With version 1.19.2
I get back a triple-slash for a http URI. But when I look into the http specification only two-slashes are allowed. I guess there are quite a few people struggling with that change.
// https://host.com/something
const urijs1 = require("urijs@1.19.1")
const uri1 = urijs1('host.com/something').scheme('https').href()
// https:///host.com/something
const urijs2 = require("urijs@1.19.2")
const uri2 = urijs2('host.com/something').scheme('https').href()
Grüezi @DaRaFF ;)
unfortunately I do believe the change is valid. What you're describing is another bug that was previously hidden by the first,
URI('foo/bar')
determines foo/bar
to be a relative directory no matter if the first directory might look like a domain (host.com
, localhost
, …). This has confused people for years. In order to make URI.js parse properly you'd need to prepend ://
to make it a relative-scheme url.
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?
I have code that looks like
I expected
uri
to befood:///test/file.csv
, but it'sfood://test/file.csv
. When re-parsinguri
thehost
is nowtest
andpath
has changed fromtest/file.csv
to/file.csv
.Is this expected, and if so, should I ensure my
path
has a leading slash? Or, is this unexpected behaviour in the library?Thanks for this library, and for your time!