-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Base URL hostnames are overridden by certain paths when constructing a URL #38963
Comments
It's the same behavior in the browser (Chrome 90) — it's probably actually correct functionality per the spec 🤔 |
I believe this is working as intended. According to the spec, the // `base` (second param) is used here because `url` (first param) has no base (it's just a relative path)
new URL('/hello/world', 'http://def') // -> { href: 'http://def/hello/world' ... }
// `base` is ignored here because `url` already has a base
new URL('http://abc/hello/world', 'http://def') // -> { href: 'http://abc/hello/world' } You might be getting confused because cc @aduh95 |
Ah that makes sense about the base interpretation, yeah - thanks for the clarification! :) If this is correct functionality per the spec for v16, would that mean it's incorrect for Node.js v14 in that case, since this does not get interpreted as a base? |
Not sure what you mean about v14 — from v10.0.0 (when |
Sorry, I should've provided an example! On v14, I ran the same command but got a different result, i.e. the path
|
Ohhhh — I made a mistake. I didn't realize what you were saying :) Yeah, something has definitely changed recently 😬 let me investigate. |
Cool, thanks - happy to provide more testing/debugging output if you need :) |
I'm guessing that the previous functionality (that which you just demontrated) was a bug, and fixed with v15.6.0 by @RaisinTen in #36613. |
Thanks for the update, looking at that PR it looks like it's included in the v14.17.0 proposal? I've just run on this version and it works okay!
I guess we can close this now? |
Ah yes, #36613 was backported to v14 with v14.17.0.
Yes, feel free to. Thank you for the issue! I'm glad I could help out ;) |
Will do and thanks for the help and clarifications - I learned something new today about Windows UNC paths! :) |
Yeah. Now let me tell you something: you might be inclined to think that in |
I did not know that either, that's really interesting and things make a lot more sense now! 🚀 - thank you very much! |
For future reference: this is a duplicate of #36559. |
v16.2.0
Darwin bisterix.local 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64
url
What steps will reproduce the bug?
Running
new URL('\\\\-', 'http://asd')
in Node.js v16.2.0 shell will override the hostname of the arbitrarily chosen base URL.How often does it reproduce? Is there a required condition?
Every time.
What is the expected behavior?
The URL is correctly constructed and the hostname is preserved:
What do you see instead?
The hostname of the base URL is overridden by the path:
Additional information
This does not occur in Node.js 14.15.4 (I haven't tested in other versions). Happy to help resolve this, although I would need some pointers for where to start :)
The text was updated successfully, but these errors were encountered: