Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! add changes in doc and refactor urlsearchparam-has
  • Loading branch information
sankalp1999 committed May 8, 2023
commit e66fe1e07328308bf535ffa510915952a1427a1e
18 changes: 16 additions & 2 deletions doc/api/url.md
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,14 @@ new URLSearchParams([

Append a new name-value pair to the query string.

#### `urlSearchParams.delete(name, value)`
#### `urlSearchParams.delete(name[, value])`

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/47885
description: added optional value argument.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: added optional value argument.
description: Add support for optional `value` argument.

-->

* `name` {string}
* `value` {string}
Expand Down Expand Up @@ -922,7 +929,14 @@ 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, value)`
#### `urlSearchParams.has(name[, value])`

<!-- YAML
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/47885
description: added optional value argument.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: added optional value argument.
description: Add support for optional `value` argument.

-->

* `name` {string}
* `value` {string}
Expand Down
8 changes: 6 additions & 2 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,8 +525,12 @@ class URLSearchParams {
}

for (let i = 0; i < list.length; i += 2) {
if (list[i] === name && (value === undefined ? true : list[i + 1] === value)) {
return true;
if (list[i] === name) {
if (value === undefined) {
return true;
} else if (list[i + 1] === value) {
return true;
}
}
}

Expand Down