- From: Timothy Gu <notifications@github.com>
- Date: Sat, 14 Jan 2017 13:31:50 -0800
- To: whatwg/url <url@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Saturday, 14 January 2017 21:32:24 UTC
TimothyGu requested changes on this pull request. > + +<div class=example id=example-searchparams-sort> + <p>It can be useful to sort the name-value pairs in a {{SearchParams}} object, in particular to + increase cache hits. This can be accomplished simply through invoking the {{SearchParams/sort()}} + method: + + <pre><code class=lang-javascript> +const url = new URL("https://example.org/?q=🏳️🌈&key=e1f7bc78"); +url.searchParams.sort(); +url.search; // "?key=e1f7bc78&q=%F0%9F%8F%B3%EF%B8%8F%E2%80%8D%F0%9F%8C%88"</code></pre> + + <p>To avoid altering the original input, e.g., for comparison purposes, construct a new + {{SearchParams}} object: + + <pre><code class=lang-javascript> +const sorted = (new URLSearchParams(url.search)).sort();</code></pre> Currently `sort()` returns void, so we either need to make `sort` return `this` or change this example. -- 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/199#pullrequestreview-16702818
Received on Saturday, 14 January 2017 21:32:24 UTC