Re: [whatwg/url] Enumerate differences between URLSearchParams and search (#495)

@domenic commented on this pull request.

This is quite helpful.

I think it'd be worth explicitly noting that using any of the mutating methods (append, delete, set, or sort) will change the URL to contain the `application/x-www-form-urlencoded`-encoded characters. And perhaps including one of the shorter examples of such mutations from #491, such as

```js
const url = new URL('http://httpbin.org/anything?a=b ~');

console.log(url.href);   // "http://httpbin.org/anything?a=b%20~"
url.searchParams.sort();
console.log(url.href);   // "http://httpbin.org/anything?a=b+%7E"
```

And including one of the reading examples would be good too, such as

```js
const url = new URL('http://httpbin.org/anything?a=~&b=%7E');
console.log(url.search); // "?a=~&b=%7E"

// Both "~"
console.log(url.searchParams.get('a'));
console.log(url.searchParams.get('b'));
```

> @@ -3102,6 +3102,23 @@ let params = new URLSearchParams({key: "730d67"})
 params.toString() // "key=730d67"</code></pre>
 </div>
 
+<div class=note>
+ <p>As {{URLSearchParams}} objects use the <a><code>application/x-www-form-urlencoded</code></a>
+ format underneath there are some difference with how it encodes certain code points compared to
+ {{URL/search}}.

and href

-- 
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/pull/495#pullrequestreview-405949547

Received on Tuesday, 5 May 2020 16:26:48 UTC