From f90eada08b3efb2264e8696d11aeb8ef22b2323f Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Thu, 13 Jul 2017 14:28:21 +0200 Subject: [PATCH] URLSearchParams can result in ? removal from URL now Changes outcome of test added in #6445. Tests for https://github.com/whatwg/url/pull/336. --- url/urlsearchparams-delete.html | 11 +++++++++-- url/urlsearchparams-sort.html | 7 +++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/url/urlsearchparams-delete.html b/url/urlsearchparams-delete.html index afc9c60c621992..d4bc0a6d26a631 100644 --- a/url/urlsearchparams-delete.html +++ b/url/urlsearchparams-delete.html @@ -41,9 +41,16 @@ var url = new URL('http://example.com/?param1¶m2'); url.searchParams.delete('param1'); url.searchParams.delete('param2'); - assert_equals(url.href, 'http://example.com/?', 'url.href has ?'); + assert_equals(url.href, 'http://example.com/', 'url.href does not have ?'); assert_equals(url.search, '', 'url.search does not have ?'); -}, 'Deleting all params keeps ? in URL'); +}, 'Deleting all params removes ? from URL'); + +test(function() { + var url = new URL('http://example.com/?'); + url.searchParams.delete('param1'); + assert_equals(url.href, 'http://example.com/', 'url.href does not have ?'); + assert_equals(url.search, '', 'url.search does not have ?'); +}, 'Removing non-existent param removes ? from URL'); diff --git a/url/urlsearchparams-sort.html b/url/urlsearchparams-sort.html index e643ed3b5a32d6..341998943c064f 100644 --- a/url/urlsearchparams-sort.html +++ b/url/urlsearchparams-sort.html @@ -47,4 +47,11 @@ } }, "URL parse and sort: " + val.input) }) + +test(function() { + const url = new URL("http://example.com/?") + url.searchParams.sort() + assert_equals(url.href, "http://example.com/") + assert_equals(url.search, "") +}, "Sorting non-existent params removes ? from URL")