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

This is a followup from [this Twitter poll](https://twitter.com/LeaVerou/status/1089634098430267398) since @annevk said there may be hope for change.
It appears that most people expect special behavior for `undefined` that in some way clears the value of the parameter. Only one in four expect the current behavior of having it cast to the string `"undefined"`.

@annevk said it might be possible to make the second argument optional, and have it default to the empty string, which would solve this.
Defaulting to deleting the parameter would also be reasonable. As far as I'm concerned, any of these options is reasonable, and better than the current behavior.

Anecdotal backstory: The reason I posted that poll in the first place was that on that day I had struggled for a while to debug why a Github API call was producing a 404 error even though the file definitely existed. It turned out that my code was using `searchParams.set("ref", this.branch)` to set the branch of the request. `this.branch` was undefined (in order to use the default branch, which was the API call default), so the API call ended up requesting a branch called "undefined", which of course didn't exist!

cc @domenic 

-- 
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

Received on Tuesday, 29 January 2019 00:25:26 UTC