Re: [whatwg/url] searchParams.set("param", undefined) should not stringify as param=undefined (#427)

I was hoping to have more discussion on this; that's why I encouraged opening the issue.

I don't think the poll doesn't clearly points any particular behavior as favored; the results are fairly evenly split. The OP advocates for some kind of clearing, but in the poll only a very slight minority (57%) seem to expect that, and among that camp folks have diverging opinions on what "clearing" means. Whereas the folks that expect the status quo are 43%. So it seems like any clearing change we make would be moving from expected-by-43% to either expected-by-30% or expected-by-27%. If anything, the poll points toward keeping the status quo!

As for my personal take, I think `"undefined"` makes the most sense because that's how normal `Map`s work. Setting to `undefined` doesn't delete an entry from the `Map`; it also doesn't convert the `undefined` into an empty string. It instead adds an entry to the Map with the given key, and `undefined` as the value. Then, when you go to stringify all entries in the Map and concatenate them into a query string, the simpler implementation would _not_ ignore `"foo"` / `undefined`, or treat that as `"foo"` / `""`. It would just treat such a pair like it does all other pairs. The OP seems to be asking for some special-casing of key/value pairs where the value is `undefined`, which to me seems more complex.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/url/issues/427#issuecomment-458632359

Received on Tuesday, 29 January 2019 17:32:45 UTC