Skip to content

Commit 079c1c7

Browse files
committed
URLSearchParams can result in ? removal from URL now
Changes outcome of test added in #6445. Tests for whatwg/url#336.
1 parent 04da785 commit 079c1c7

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

url/urlsearchparams-delete.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,16 @@
4141
var url = new URL('http://example.com/?param1&param2');
4242
url.searchParams.delete('param1');
4343
url.searchParams.delete('param2');
44-
assert_equals(url.href, 'http://example.com/?', 'url.href has ?');
44+
assert_equals(url.href, 'http://example.com/', 'url.href does not have ?');
4545
assert_equals(url.search, '', 'url.search does not have ?');
46-
}, 'Deleting all params keeps ? in URL');
46+
}, 'Deleting all params removes ? from URL');
47+
48+
test(function() {
49+
var url = new URL('http://example.com/?');
50+
url.searchParams.delete('param1');
51+
assert_equals(url.href, 'http://example.com/', 'url.href does not have ?');
52+
assert_equals(url.search, '', 'url.search does not have ?');
53+
}, 'Removing non-existent param removes ? from URL');
4754
</script>
4855
</head>
4956
</html>

url/urlsearchparams-sort.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,11 @@
4747
}
4848
}, "URL parse and sort: " + val.input)
4949
})
50+
51+
test(function() {
52+
const url = new URL("http://example.com/?")
53+
url.searchParams.sort()
54+
assert_equals(url.href, "http://example.com/")
55+
assert_equals(url.search, "")
56+
}, "Sorting non-existent params removes ? from URL")
5057
</script>

0 commit comments

Comments
 (0)