-
Notifications
You must be signed in to change notification settings - Fork 141
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
URLSearchParams append/set: variadic values argument? #762
Comments
I'm generally +1 on the idea but suggest that it should be separate function.... But can live with this approach. |
It may be a bit of a hazard that a non variadic function suddenly becomes variadic. Is this something we have done previously? |
I'm not sure, variadic made sense to me because of |
Operations have had new parameters added previously many times, right? Is there something that makes the variadic case more hazardous? If the hazard is that someone might have passed an argument by mistake which will no longer be ignored, it seems to apply equally to both. |
As I said, I can live with the variadic approach. I don't prefer it because discoverability is weakened. If I'm on one runtime that has implemented this and I write |
That’s a good point. I have no strong preference myself for expanded signature vs new method but this appeared pretty clean to me and seemed to avoid confusion with other possible notions of “appending all”: this issue was spawned from another regarding a proposed |
When assembling URLs with parameters where the same key is used with multiple values, I’ve often needed to set those multiple values at once and found the URLSearchParams API surface slightly clunky for this. I’d mentioned this in another issue and @annevk pointed out that this could be facilitated backwards-compatibly without any new API surface just by making the
set
andappend
operations variadic. Instead of:They would be:
An example of what this change facilitates would be the filtering or mapping of parameters as may occur when applying application-specific URL canonicalization rules or setting parameters based on the current state of a search form. Instead of:
One could write:
Is there interest from others in this change? It’s a minor ergonomics improvement, but I’d guess it’s also pretty low-hanging from an implementer POV.
The text was updated successfully, but these errors were encountered: