Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency between Chrome/Node.js in url parsing spec #345

Closed
bcoe opened this issue Sep 20, 2017 · 2 comments
Closed

Inconsistency between Chrome/Node.js in url parsing spec #345

bcoe opened this issue Sep 20, 2017 · 2 comments

Comments

@bcoe
Copy link

bcoe commented Sep 20, 2017

I was digging into a Windows bug in Node and found an inconsistency between Chrome's implementation of the URL spec and what's written in the file-slash-state spec.

Reading the spec, it sounds like if I resolve:

new URL('/C:/foo', 'file:///D:/bar')

I would expect the URL to resolve as:

/D:/foo

Chrome's Parse:

new URL('/C:/foo', 'file:///D:/bar')
URL {href: "file:///C:/foo", origin: "file://", protocol: "file:", username: "", password: ""}

Firefox's Parse

new URL("/C:/a/b/c/module.mjs", "file://D:/foo/bar")
URL { href: "file:///C:/a/b/c/module.mjs", origin: "null", protocol: "file:", username: "", password: "", host: "", hostname: "", port: "", pathname: "/C:/a/b/c/module.mjs", search: "" }

Node's Parse

new URL('/C:/foo', 'file:///D:/bar')
{
  href: file:///D:/C:/foo
  protocol: file:
}

wow, that's really wrong definitely should be fixed.

Path Forward

It feels to me like Chrome's implementation is the most reasonable; if I resolve a URL C:/foo/bar it doesn't really make sense to me that I'd end up with a URL D:/foo/bar this is almost surely pointing to an invalid file path.

It might be worth updating this section of the spec to reflect Chrome's implementation (it might just be that myself and @bmeck are reading it wrong).

CC: @bmeck, @TimothyGu, @domenic @annevk, @jasnell

UPDATE: it looks like both Safari and Firefox parse the same as Chrome, this seems to point towards Brad and I misreading the spec?

@rmisev
Copy link
Member

rmisev commented Sep 20, 2017

This bug already fixed in the spec, see #343.

@bcoe
Copy link
Author

bcoe commented Sep 20, 2017

@rmisev wonderful -- if I'm reading the new instructions properly, we now only set the drive section from the base if there's no drive section in the path; matching the behavior we're seeing in Chrome, Firefox, etc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants