From 04b04f574051d33f96eb1f1519fbf9df8cade0a5 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Thu, 12 Jan 2017 13:44:35 +0100 Subject: [PATCH 1/2] URLSearchParams.prototype.sort() See https://github.com/whatwg/url/issues/26 for context. --- url/urlsearchparams-sort.html | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 url/urlsearchparams-sort.html diff --git a/url/urlsearchparams-sort.html b/url/urlsearchparams-sort.html new file mode 100644 index 00000000000000..a5e5b082eea606 --- /dev/null +++ b/url/urlsearchparams-sort.html @@ -0,0 +1,27 @@ + + + + +
+ From 2630e057ce25b47ed7188cc633a07b6f5f40b378 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 13 Jan 2017 16:12:48 +0100 Subject: [PATCH 2/2] test a bit more --- url/urlsearchparams-sort.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/url/urlsearchparams-sort.html b/url/urlsearchparams-sort.html index a5e5b082eea606..50e0adb211ba51 100644 --- a/url/urlsearchparams-sort.html +++ b/url/urlsearchparams-sort.html @@ -12,6 +12,14 @@ { "input": "\uFFFD=x&\uFFFC&\uFFFD=a", "output": [["\uFFFC", ""], ["\uFFFD", "x"], ["\uFFFD", "a"]] + }, + { + "input": "ffi&🌈", // 🌈 > code point, but < code unit because two code units + "output": [["🌈", ""], ["ffi", ""]] + }, + { + "input": "é&e\uFFFD&e\u0301", + "output": [["e\u0301", ""], ["e\uFFFD", ""], ["é", ""]] } ].forEach((val) => { test(() => { @@ -23,5 +31,16 @@ i++ } }, "Parse and sort: " + val.input) + + test(() => { + let url = new URL("?" + val.input, "https://example/") + url.searchParams.sort() + let params = new URLSearchParams(url.search), + i = 0 + for(let param of params) { + assert_array_equals(param, val.output[i]) + i++ + } + }, "URL parse and sort: " + val.input) })