summaryrefslogtreecommitdiff
path: root/doc/api
diff options
context:
space:
mode:
authorSankalp Shubham <sankalp.shubham99@gmail.com>2023-05-14 20:05:19 +0530
committerGitHub <noreply@github.com>2023-05-14 14:35:19 +0000
commit9f3aacbc27ac3f377d225ecd51aecb0f3de12566 (patch)
tree85bc557766df0fcb80d9fbb1cf35fbac60a7eb90 /doc/api
parentabb1c45af774ae3caaa449ddcbfe44143a98e9c7 (diff)
downloadnode-new-9f3aacbc27ac3f377d225ecd51aecb0f3de12566.tar.gz
url: add value argument to has and delete methods
The change aims to add value argument to two methods of URLSearchParams class i.e the has method and the delete method. For has method, if value argument is provided, then use it to check for presence. For delete method, if value argument provided, use it to delete. Fixes: https://github.com/nodejs/node/issues/47883 PR-URL: https://github.com/nodejs/node/pull/47885 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Diffstat (limited to 'doc/api')
-rw-r--r--doc/api/url.md34
1 files changed, 30 insertions, 4 deletions
diff --git a/doc/api/url.md b/doc/api/url.md
index 06abd2910b..a07cda465c 100644
--- a/doc/api/url.md
+++ b/doc/api/url.md
@@ -859,11 +859,22 @@ new URLSearchParams([
Append a new name-value pair to the query string.
-#### `urlSearchParams.delete(name)`
+#### `urlSearchParams.delete(name[, value])`
+
+<!-- YAML
+changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/47885
+ description: Add support for optional `value` argument.
+-->
* `name` {string}
+* `value` {string}
+
+If `value` is provided, removes all name-value pairs
+where name is `name` and value is `value`..
-Remove all name-value pairs whose name is `name`.
+If `value` is not provided, removes all name-value pairs whose name is `name`.
#### `urlSearchParams.entries()`
@@ -918,12 +929,27 @@ are no such pairs, `null` is returned.
Returns the values of all name-value pairs whose name is `name`. If there are
no such pairs, an empty array is returned.
-#### `urlSearchParams.has(name)`
+#### `urlSearchParams.has(name[, value])`
+
+<!-- YAML
+changes:
+ - version: REPLACEME
+ pr-url: https://github.com/nodejs/node/pull/47885
+ description: Add support for optional `value` argument.
+-->
* `name` {string}
+* `value` {string}
* Returns: {boolean}
-Returns `true` if there is at least one name-value pair whose name is `name`.
+Checks if the `URLSearchParams` object contains key-value pair(s) based on
+`name` and an optional `value` argument.
+
+If `value` is provided, returns `true` when name-value pair with
+same `name` and `value` exists.
+
+If `value` is not provided, returns `true` if there is at least one name-value
+pair whose name is `name`.
#### `urlSearchParams.keys()`