-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
url.parse now encodes components #2113
Comments
This should go on to https://github.com/joyent/node/wiki/API-changes-between-v0.10-and-v0.12 but does anyone have a git ref that can explain the context around this? |
@mojodna any idea if this difference is also between 0.12 and 0.10? |
Interesting. See nodejs/node-v0.x-archive#5474 and linked issues. |
@Fishrock123 hmm, seems like they put two patches up (38149bb, 17a379e) to fix the same bug and reverted the one in http (7124387), leaving url. Full backwards compatibilty?.. nahh |
The inability to cleanly round-trip is my biggest complaint about the regression, as it leads to code like this (plus, I'm probably forgetting to decode some components): if (semver.satisfies(process.version, ">=0.11.0")) {
// Node 0.12 changes the behavior of url.parse such that components are
// url-encoded
uri.hash = decodeURIComponent(uri.hash);
uri.pathname = decodeURIComponent(uri.pathname);
uri.path = decodeURIComponent(uri.path);
uri.href = decodeURIComponent(uri.href);
} (from mojodna/tilelive-http@a74871c#diff-168726dbe96b3ce427e7fedce31bb0bcR90) |
Crap we should probably actually fix this for 4.0.0.. hmmm |
cc @bnoordhuis since he reverted the http patch. |
@Fishrock123 put it on the 4.0.0 milestone if you feel strongly enough about it and think it needs to be done |
something needs to be done, I'm not sure if I should revert it or document it.. |
My preference (for whatever it's worth) would be to revert it, solely on the basis of round-tripping not working. |
The argument @isaacs made for it was that it is how chrome handles parsing, which is true. This is also on 0.12, so there is that to consider. |
@nodejs/tsc we need a position on this, it's been tagged for 4.0.0 but the current trajectory suggests it's not going to get in and we'll be stuck with current behaviour into LTS. |
Just jumping in because of the tsc mention. IMO whichever opinion is the path of least surprise. Meaning, whatever more closely aligns with browser functionality. |
For posterity, what we now do is what chrome does. |
Misspoke in my last post. We have been attempting to bring the URL parser to match the specification (https://url.spec.whatwg.org), and Chrome simply aligns to that. Since it always returns an encoded string you can likewise always decode the return value. I believe this is fairly standard among all browser implementations. |
there is one difference between our implementation and Chrome though: io.js v3.2.0
Chrome
|
Ummmm. Huh. I don't know enough about the URL specs to understand. |
We have to make a call on this asap, I'm inclined to leave it as it is and just make sure it's listed in the breaking changes. The |
At this point I'd rather us not make a major change this close to cutting
|
@targos Good point on the JS API. Looks to be the same in Firefox as well. Anyone know of any API's that accept a URL are automatically encoded? I'm pretty sure they're aren't. If that's the case it does seem inconsistent to only encode the URL with this API. |
Fixed in 47e5cf7 |
Fixes: nodejs#2113 Ref: 17a379e PR-URL: nodejs#2605 Reviewed-By: jasnell - James M Snell <jasnell@gmail.com> Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com> Reviewed-By: mscdex - Brian White <mscdex@mscdex.net>
This behavior changed between Node-0.10 and 0.12/iojs and does not appear to be documented anywhere.
io.js v2.3.3:
node.js v0.10.39:
This also means that URIs no longer roundtrip:
iojs v2.3.3
node.js v0.10.39:
The text was updated successfully, but these errors were encountered: