- From: Domenic Denicola <notifications@github.com>
- Date: Tue, 28 Apr 2020 17:51:21 -0700
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/url/issues/478/620929779@github.com>
My take on the history (from #18) is that `URLSearchParams` is misnamed and misused. It was designed as a kind of `application/x-www-form-urlencoded` representation manipulator, to represent form data in that form. But instead of being named `ApplicationXWWWFormURLEncodedParams`, it was misnamed `URLSearchParams`. And then things got worse when one got attached to every `URL` object via the `searchParams` property, in a way where interacting with the new `url.searchParams` property would cause results inconsistent with interacting with the URL's `search` property, because `search` uses URL query rules instead of `application/x-www-form-urlencoded` rules. So although we have cross-browser uniformity, we unfortunately have a massive web developer footgun. There are a few ways out of this: 1. Do nothing. If you want to actually manipulate a URL's query string according to URL query rules, you need to do so manually or with a dedicated library, and `url.searchParams` is not a good fit for you. 2. (This issue's proposal, IIUC) Make `URLSearchParams` have an internal "mode", e.g. "`application/x-www-form-urlencoded` mode" vs. "URL search params mode". `url.searchParams` can be an instance of `URLSearchParams` which uses the "URL search params mode", whereas `new URLSearchParams()` can use the "`application/x-www-form-urlencoded` mode". 3. Change `URLSearchParams` to always operate according to the URL query rules. Optionally, introduce a new object (e.g. `ApplicationXWWWFormURLEncodedParams`) which can be used for representing form data. I have always favored (3), but been unsure if we could get away with it; there are compat risks. The proposal of (2) is novel, but I'm not sure if it's a great idea; it seems like it'd add confusion and I don't know how much compat risk it would really mitigate. -- 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/478#issuecomment-620929779
Received on Wednesday, 29 April 2020 00:51:34 UTC