-
-
Notifications
You must be signed in to change notification settings - Fork 16.2k
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
Replace node:querystring
with URLSearchParams
#5731
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
There is much that is not defined in specifications for various reasons. JSONP itself was never formalized, for example. But this isn't very relevant here. The problem at hand isn't so much which key to parse first -- although express does guarantee the order and we wouldn't want to change that. The bigger issue with your change is actually that you're discarding data. The result of parsing
but with your change, the result is:
Storing duplicate key query string values as an ordered list is standardized in the URL spec and is consistent across query string parser impls in the JS and Web API ecosystems. It is done this way in node, > new URLSearchParams('callback=something&callback=somethingelse').getAll('callback');
(2) ['something', 'somethingelse'] |
df011ff
to
38ab38d
Compare
I've fixed the USP parser, I just had to manually convert all keys to a POJO using |
Question: is there any value in adding this as an additional option instead of removing the old option entirely? |
I don't think so since both options should parse the options the same already (sort of). We'd also decouple from Node a bit. |
Exactly my concern when raising this question. Is there a downside to keeping the old behavior around? The only thing I could think of is loading in the extra lib, but frankly unless it can be proven to make a meaningful difference in startup time I am inclined to take that penalty so that we avoid increased issue volume on the project.
This is a non-goal of the project right now. Maybe someday when we are not monkey patching node built ins it could be, but I am not confident we will get to a place where In general I would prefer to land a new option to use |
A couple other concerns related to having extra dependencies might be increased supply chain risk and increased risk of deprecation warnings. The latter has been a headache for me in some projects I maintain where a library gets deprecated and then there's difficulty in upgrading for a number of reasons - e.g. the latest version is deprecated and we need to move to a new library, the latest in a minor is deprecated so we need to move to a new major but it introduces breaking changes, the deprecation is down the dependency tree and there's a dependency in between that's unmaintained or otherwise won't update.
I'm sure you're aware, but there's also a burden of having to support multiple options. It's more code paths, is harder to get bug reporters to clearly communicate which option they're using, etc. I also think it's harder as a user to have multiple ways to do things as it means you have to read more documentation to understand how things work, might find tutorials or stackoverflow answers talking about the other way, etc. |
But this one is a node built in. I do no think this is applicable in this case.
I am, and usually I would oppose an addition adding an alternate with duplicate functionality, but in this case it is adding support for a web standard where none existed when the original was written so to me that is a good thing. The thing I am worried about is that we missed something required by come applications and have to revisit this decision after releasing. I would rather take the low cost supporting two options than have to re-litigate this discussion in 3 months when we release v5 and find out
Totally agree here, but with so few folks who are regularly showing up to support and answer users questions and issues we have to make some compromises. In this case I believe that the risk of switching without a fallback to the ~10y old behavior is high enough to warrant the decision, but I am happy to hear differently if you (or anyone else) strongly believe this is best and bring the backing argument for it. |
As discussed in #5723, I've replaced
node:querystring
withURLSearchParams
for better interoperability and standards compliance.The "multiple keys" scenario isn't defined by the URL and URLSearchParams spec so the JSONP test for checking that the first
callback
parameter is used, is failing.You can read more here: https://www.rfc-editor.org/rfc/rfc3986#section-3.4 https://url.spec.whatwg.org/#urlsearchparams
❔ How do we want to proceed with this?
Supersedes #5730
cc: @ctcpip