summaryrefslogtreecommitdiff
path: root/ext/url/00_url.js
diff options
context:
space:
mode:
authorLino Le Van <11367844+lino-levan@users.noreply.github.com>2023-07-02 08:26:48 -0700
committerGitHub <noreply@github.com>2023-07-02 17:26:48 +0200
commit17ddf2f97c58db0b6825809a8bc325f0bda65b1b (patch)
tree7561f7b86e79973f3d4e732e16c7963de195ba42 /ext/url/00_url.js
parentd8e8e60f9f32ffce785b2efd71cd78b337a5352c (diff)
feat(ext/url): URLSearchParams two-argument delete() and has() (#19654)
Diffstat (limited to 'ext/url/00_url.js')
-rw-r--r--ext/url/00_url.js34
1 files changed, 27 insertions, 7 deletions
diff --git a/ext/url/00_url.js b/ext/url/00_url.js
index 2a238eae1..65cde2ce2 100644
--- a/ext/url/00_url.js
+++ b/ext/url/00_url.js
@@ -169,19 +169,31 @@ class URLSearchParams {
/**
* @param {string} name
+ * @param {string} [value]
*/
- delete(name) {
+ delete(name, value = undefined) {
webidl.assertBranded(this, URLSearchParamsPrototype);
const prefix = "Failed to execute 'append' on 'URLSearchParams'";
webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters.USVString(name, prefix, "Argument 1");
const list = this[_list];
let i = 0;
- while (i < list.length) {
- if (list[i][0] === name) {
- ArrayPrototypeSplice(list, i, 1);
- } else {
- i++;
+ if (value === undefined) {
+ while (i < list.length) {
+ if (list[i][0] === name) {
+ ArrayPrototypeSplice(list, i, 1);
+ } else {
+ i++;
+ }
+ }
+ } else {
+ value = webidl.converters.USVString(value, prefix, "Argument 2");
+ while (i < list.length) {
+ if (list[i][0] === name && list[i][1] === value) {
+ ArrayPrototypeSplice(list, i, 1);
+ } else {
+ i++;
+ }
}
}
this.#updateUrlSearch();
@@ -228,13 +240,21 @@ class URLSearchParams {
/**
* @param {string} name
+ * @param {string} [value]
* @return {boolean}
*/
- has(name) {
+ has(name, value = undefined) {
webidl.assertBranded(this, URLSearchParamsPrototype);
const prefix = "Failed to execute 'has' on 'URLSearchParams'";
webidl.requiredArguments(arguments.length, 1, prefix);
name = webidl.converters.USVString(name, prefix, "Argument 1");
+ if (value !== undefined) {
+ value = webidl.converters.USVString(value, prefix, "Argument 2");
+ return ArrayPrototypeSome(
+ this[_list],
+ (entry) => entry[0] === name && entry[1] === value,
+ );
+ }
return ArrayPrototypeSome(this[_list], (entry) => entry[0] === name);
}