- From: Darien Maillet Valentine <notifications@github.com>
- Date: Tue, 14 Mar 2023 05:40:49 -0700
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/url/issues/762@github.com>
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](https://github.com/whatwg/url/issues/461#issuecomment-1455307890) that this could be facilitated backwards-compatibly without any new API surface just by making the `set` and `append` operations variadic. Instead of: ```webidl interface URLSearchParams { /* ... */ undefined append(USVString name, USVString value); undefined set(USVString name, USVString value); }; ``` They would be: ```webidl interface URLSearchParams { /* ... */ undefined append(USVString name, USVString ...values); undefined set(USVString name, USVString ...values); }; ``` 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 updating parameters based on the current state of a search form: ```js usp.set("foo", ...usp.getAll("foo").filter(isFooValue)); ``` 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 implementor POV. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/url/issues/762 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/url/issues/762@github.com>
Received on Tuesday, 14 March 2023 12:41:01 UTC