Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url: add value argument to has and delete methods #47885

Merged
merged 13 commits into from May 14, 2023

Conversation

sankalp1999
Copy link
Contributor

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: #47883

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/url

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation. labels May 5, 2023
@sankalp1999 sankalp1999 marked this pull request as draft May 5, 2023 19:05
Copy link
Member

@anonrig anonrig left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution.

Can you run git node wpt url and update URL web-platform tests? You need to install node-core-utils in order to get access to the script.

Additionally, can you update the documentation url.md to reflect the changes?

@sankalp1999
Copy link
Contributor Author

@anonrig
Thanks for the direction, will do these.

Yes, I will update the documentation accordingly.

@sankalp1999 sankalp1999 force-pushed the url-search-param-has-delete branch 2 times, most recently from 6514d52 to 7cc66e4 Compare May 5, 2023 20:59
lib/internal/url.js Outdated Show resolved Hide resolved
lib/internal/url.js Outdated Show resolved Hide resolved
lib/internal/url.js Outdated Show resolved Hide resolved
lib/internal/url.js Outdated Show resolved Hide resolved
@sankalp1999 sankalp1999 marked this pull request as ready for review May 6, 2023 07:05
doc/api/url.md Outdated Show resolved Hide resolved
@sankalp1999
Copy link
Contributor Author

sankalp1999 commented May 6, 2023

@anonrig need your help.

one of the WPT is not working.
file name is: idlharness.any.js. I think it's this one and it's calling an internal test

  "historical.any.js": {
    "fail": {
      "expected": [
        "searchParams on location object",
        "URL: no structured serialize/deserialize support",
        "URLSearchParams: no structured serialize/deserialize support"
      ]
    }
  },
  "idlharness.any.js": {
    "fail": {
      "unexpected": [
        "URLSearchParams interface: operation delete(USVString)",
        "URLSearchParams interface: operation has(USVString)"
      ]
    }
  },
  "javascript-urls.window.js": {
    "skip": "requires document.body reference"
  },
  "percent-encoding.window.js": {
    "skip": "TODO: port from .window.js"
  },
  "url-setters-a-area.window.js": {
    "skip": "already tested in url-setters.any.js"
  }
}

Ran 30/33 tests, 3 skipped, 28 passed, 1 expected failures, 1 unexpected failures, 0 unexpected passes
[redacted]/node/test/common/wpt.js:751
        throw new Error(
        ^

Error: Found 1 unexpected failures. Consider updating test/wpt/status/url.json for these files:
idlharness.any.js
    at process.<anonymous> ([redacted]/node/test/common/wpt.js:751:15)
    at process.emit (node:events:511:28)

Node.js v21.0.0-pre
Command: out/Release/node [redacted]node/wpt/test-url.js

@sankalp1999
Copy link
Contributor Author

sankalp1999 commented May 6, 2023

I think it's supposed to fail because the URLSearchParams interface changes haven't reached the main branch.

https://github.com/whatwg/url/pull/735/files

 "idlharness.any.js": {
    "fail": {
      "unexpected": [
        "URLSearchParams interface: operation delete(USVString)",
        "URLSearchParams interface: operation has(USVString)"
      ]
    }
  }
  

@sankalp1999 sankalp1999 requested a review from anonrig May 7, 2023 06:51
@sankalp1999
Copy link
Contributor Author

@anonrig need your help with above.

@debadree25
Copy link
Member

debadree25 commented May 8, 2023

Hey the spec PR has landed, I am restarting the CI jobs should pass now i think

@debadree25
Copy link
Member

Ah i think setting value = undefined is whats required since value is option per the spec

@sankalp1999
Copy link
Contributor Author

Thanks @debadree25 I think that fixed it.
Have pushed the changes. Let's run CI. thanks.
Screenshot 2023-05-08 at 3 06 12 PM

Copy link
Member

@anonrig anonrig left a comment

Choose a reason for hiding this comment

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

The tests are failing due to the WPT update, and unrelated to this pull request. I'll update the WPT in a different pull request and fix the issues, leaving you to only implement what this pull request was originally intended to include.

Edit: Actually it seems they are related. Only updating the WPT did not break any tests. @sankalp1999

doc/api/url.md Outdated Show resolved Hide resolved
lib/internal/url.js Outdated Show resolved Hide resolved
@sankalp1999
Copy link
Contributor Author

sankalp1999 commented May 8, 2023

@anonrig @debadree25

I synced my branch, made a new node build. then ran sudo make test -j32

A couple of tests are failing. These are different from the ones that are failing in the PR (edit: I mean Github workflow). I will paste those messages in the next comment for visibility.

/Library/Developer/CommandLineTools/usr/bin/make -s jstest
ninja: Entering directory `out/Release'
ninja: no work to do.
=== release test-http-server-request-timeouts-mixed ===                       
Path: parallel/test-http-server-request-timeouts-mixed
node:assert:399
    throw err;
    ^

AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

  assert(request2.completed)

    at Timeout._onTimeout (/Users/sshubham/Desktop/open_source/node/test/parallel/test-http-server-request-timeouts-mixed.js:108:5)
    at listOnTimeout (node:internal/timers:573:17)
    at process.processTimers (node:internal/timers:514:7) {
  generatedMessage: true,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

Node.js v21.0.0-pre
Command: out/Release/node [redacted]/node/test/parallel/test-http-server-request-timeouts-mixed.js


=== release test-net-connect-memleak ===                                      
Path: parallel/test-net-connect-memleak
node:events:489
      throw er; // Unhandled 'error' event
      ^

Error: read ECONNRESET
    at TCP.onStreamRead (node:internal/stream_base_commons:217:20)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  errno: -54,
  code: 'ECONNRESET',
  syscall: 'read'
}

Node.js v21.0.0-pre
Command: out/Release/node --expose-gc [redacted]/node/test/parallel/test-net-connect-memleak.js


[06:22|% 100|+ 3859|-   2]: Done                                              

Failed tests:
out/Release/node [redacted]/node/test/parallel/test-http-server-request-timeouts-mixed.js
out/Release/node --expose-gc [redacted]/node/test/parallel/test-net-connect-memleak.js
make[1]: *** [jstest] Error 1
make: *** [test] Error 2

@nodejs-github-bot nodejs-github-bot merged commit 9f3aacb into nodejs:main May 14, 2023
55 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 9f3aacb

@debadree25
Copy link
Member

Thank you for your contribution @sankalp1999 🎉🎉

@sankalp1999
Copy link
Contributor Author

sankalp1999 commented May 14, 2023

This is my first contribution to node. Looking forward to contribute more in the future.

I am grateful to @anonrig , @debadree25 and all the reviewers who helped me and reviewed my code.

I also improved my learning of the node repository and got an idea of how things work here.

Thanks a lot folks.

image

targos pushed a commit that referenced this pull request May 14, 2023
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: #47883
PR-URL: #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>
targos pushed a commit that referenced this pull request May 15, 2023
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: #47883
PR-URL: #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>
targos added a commit that referenced this pull request May 15, 2023
Notable changes:

doc:
  * add ovflowd to collaborators (Claudio Wunder) #47844
http:
  * (SEMVER-MINOR) prevent writing to the body when not allowed by HTTP spec (Gerrard Lindsay) #47732
sea:
  * (SEMVER-MINOR) add option to disable the experimental SEA warning (Darshan Sen) #47588
test_runner:
  * (SEMVER-MINOR) add `skip`, `todo`, and `only` shorthands to `test` (Chemi Atlow) #47909
url:
  * (SEMVER-MINOR) add value argument to `URLSearchParams` `has` and `delete` methods (Sankalp Shubham) #47885

PR-URL: #48020
targos added a commit that referenced this pull request May 16, 2023
Notable changes:

doc:
  * add ovflowd to collaborators (Claudio Wunder) #47844
http:
  * (SEMVER-MINOR) prevent writing to the body when not allowed by HTTP spec (Gerrard Lindsay) #47732
sea:
  * (SEMVER-MINOR) add option to disable the experimental SEA warning (Darshan Sen) #47588
test_runner:
  * (SEMVER-MINOR) add `skip`, `todo`, and `only` shorthands to `test` (Chemi Atlow) #47909
url:
  * (SEMVER-MINOR) add value argument to `URLSearchParams` `has` and `delete` methods (Sankalp Shubham) #47885

PR-URL: #48020
@anonrig
Copy link
Member

anonrig commented Sep 6, 2023

This PR includes a change in benchmark/common.js and an update in web-platform-tests. It shouldn't have the do-not-land-v18 label.

@ruyadorno
Copy link
Member

I'll try to land it in the current v18.18.0 proposal and run CI to see how it looks like, in case CI is green this should be good to go.

@ruyadorno ruyadorno removed the dont-land-on-v18.x PRs that should not land on the v18.x-staging branch and should not be released in v18.x. label Sep 6, 2023
ruyadorno pushed a commit that referenced this pull request Sep 6, 2023
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: #47883
PR-URL: #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>
ruyadorno added a commit that referenced this pull request Sep 6, 2023
Notable changes:

net:
  * add autoSelectFamily global getter and setter (Paolo Insogna) #45777
url:
  * (SEMVER-MINOR) add value argument to has and delete methods (Sankalp Shubham) #47885

PR-URL: #49220
ruyadorno added a commit that referenced this pull request Sep 8, 2023
Notable changes:

crypto:
  * update root certificates to NSS 3.90 (Node.js GitHub Bot) #48416
doc:
  * add kvakil to collaborators (Keyhan Vakil) #48449
esm:
  * (SEMVER-MINOR) add `--import` flag (Moshe Atlow) #43942
net:
  * add autoSelectFamily global getter and setter (Paolo Insogna) #45777
url:
  * (SEMVER-MINOR) add value argument to has and delete methods (Sankalp Shubham) #47885

PR-URL: #49220
@ruyadorno ruyadorno mentioned this pull request Sep 8, 2023
ruyadorno added a commit that referenced this pull request Sep 10, 2023
Notable changes:

crypto:
  * update root certificates to NSS 3.90 (Node.js GitHub Bot) #48416
doc:
  * add kvakil to collaborators (Keyhan Vakil) #48449
esm:
  * (SEMVER-MINOR) add `--import` flag (Moshe Atlow) #43942
net:
  * add autoSelectFamily global getter and setter (Paolo Insogna) #45777
url:
  * (SEMVER-MINOR) add value argument to has and delete methods (Sankalp Shubham) #47885

PR-URL: #49220
ruyadorno added a commit that referenced this pull request Sep 10, 2023
Notable changes:

crypto:
  * update root certificates to NSS 3.90 (Node.js GitHub Bot) #48416
doc:
  * add vmoroz to collaborators (Vladimir Morozov) #48527
  * add kvakil to collaborators (Keyhan Vakil) #48449
esm:
  * (SEMVER-MINOR) add `--import` flag (Moshe Atlow) #43942
net:
  * add autoSelectFamily global getter and setter (Paolo Insogna) #45777
url:
  * (SEMVER-MINOR) add value argument to has and delete methods (Sankalp Shubham) #47885

PR-URL: #49220
ruyadorno added a commit that referenced this pull request Sep 11, 2023
Notable changes:

crypto:
  * update root certificates to NSS 3.90 (Node.js GitHub Bot) #48416
doc:
  * add vmoroz to collaborators (Vladimir Morozov) #48527
  * add kvakil to collaborators (Keyhan Vakil) #48449
esm:
  * (SEMVER-MINOR) add `--import` flag (Moshe Atlow) #43942
events:
  * (SEMVER-MINOR) allow safely adding listener to abortSignal (Chemi Atlow) #48596
net:
  * add autoSelectFamily global getter and setter (Paolo Insogna) #45777
url:
  * (SEMVER-MINOR) add value argument to has and delete methods (Sankalp Shubham) #47885

PR-URL: #49220
ruyadorno added a commit that referenced this pull request Sep 11, 2023
Notable changes:

build:
  * sync libuv header change (Jiawen Geng) #48078
crypto:
  * update root certificates to NSS 3.90 (Node.js GitHub Bot) #48416
deps:
  * add missing thread-common.c in uv.gyp (Santiago Gimeno) #48078
  * upgrade to libuv 1.46.0 (Santiago Gimeno) #48078
  * upgrade to libuv 1.45.0 (Santiago Gimeno) #48078
doc:
  * add vmoroz to collaborators (Vladimir Morozov) #48527
  * add kvakil to collaborators (Keyhan Vakil) #48449
esm:
  * (SEMVER-MINOR) add `--import` flag (Moshe Atlow) #43942
events:
  * (SEMVER-MINOR) allow safely adding listener to abortSignal (Chemi Atlow) #48596
fs, stream:
  * initial `Symbol.dispose` and `Symbol.asyncDispose` support (Moshe Atlow) #48518
net:
  * add autoSelectFamily global getter and setter (Paolo Insogna) #45777
url:
  * (SEMVER-MINOR) add value argument to has and delete methods (Sankalp Shubham) #47885

PR-URL: #49220
ruyadorno added a commit that referenced this pull request Sep 12, 2023
Notable changes:

build:
  * sync libuv header change (Jiawen Geng) #48078
crypto:
  * update root certificates to NSS 3.93 (Node.js GitHub Bot) #49341
  * update root certificates to NSS 3.90 (Node.js GitHub Bot) #48416
deps:
  * add missing thread-common.c in uv.gyp (Santiago Gimeno) #48078
  * upgrade to libuv 1.46.0 (Santiago Gimeno) #48078
  * upgrade to libuv 1.45.0 (Santiago Gimeno) #48078
doc:
  * add atlowChemi to collaborators (atlowChemi) #48757
  * add vmoroz to collaborators (Vladimir Morozov) #48527
  * add kvakil to collaborators (Keyhan Vakil) #48449
esm:
  * (SEMVER-MINOR) add `--import` flag (Moshe Atlow) #43942
events:
  * (SEMVER-MINOR) allow safely adding listener to abortSignal (Chemi Atlow) #48596
fs, stream:
  * initial `Symbol.dispose` and `Symbol.asyncDispose` support (Moshe Atlow) #48518
net:
  * add autoSelectFamily global getter and setter (Paolo Insogna) #45777
url:
  * (SEMVER-MINOR) add value argument to has and delete methods (Sankalp Shubham) #47885

PR-URL: #49220
ruyadorno added a commit that referenced this pull request Sep 13, 2023
Notable changes:

build:
  * sync libuv header change (Jiawen Geng) #48078
crypto:
  * update root certificates to NSS 3.93 (Node.js GitHub Bot) #49341
  * update root certificates to NSS 3.90 (Node.js GitHub Bot) #48416
deps:
  * add missing thread-common.c in uv.gyp (Santiago Gimeno) #48078
  * upgrade to libuv 1.46.0 (Santiago Gimeno) #48078
  * upgrade to libuv 1.45.0 (Santiago Gimeno) #48078
doc:
  * add atlowChemi to collaborators (atlowChemi) #48757
  * add vmoroz to collaborators (Vladimir Morozov) #48527
  * add kvakil to collaborators (Keyhan Vakil) #48449
esm:
  * (SEMVER-MINOR) add `--import` flag (Moshe Atlow) #43942
events:
  * (SEMVER-MINOR) allow safely adding listener to abortSignal (Chemi Atlow) #48596
fs, stream:
  * initial `Symbol.dispose` and `Symbol.asyncDispose` support (Moshe Atlow) #48518
net:
  * add autoSelectFamily global getter and setter (Paolo Insogna) #45777
url:
  * (SEMVER-MINOR) add value argument to has and delete methods (Sankalp Shubham) #47885

PR-URL: #49220
ruyadorno added a commit that referenced this pull request Sep 17, 2023
Notable changes:

build:
  * sync libuv header change (Jiawen Geng) #48078
crypto:
  * update root certificates to NSS 3.93 (Node.js GitHub Bot) #49341
  * update root certificates to NSS 3.90 (Node.js GitHub Bot) #48416
deps:
  * add missing thread-common.c in uv.gyp (Santiago Gimeno) #48078
  * upgrade to libuv 1.46.0 (Santiago Gimeno) #48078
  * upgrade to libuv 1.45.0 (Santiago Gimeno) #48078
doc:
  * add atlowChemi to collaborators (atlowChemi) #48757
  * add vmoroz to collaborators (Vladimir Morozov) #48527
  * add kvakil to collaborators (Keyhan Vakil) #48449
esm:
  * (SEMVER-MINOR) add `--import` flag (Moshe Atlow) #43942
events:
  * (SEMVER-MINOR) allow safely adding listener to abortSignal (Chemi Atlow) #48596
fs, stream:
  * initial `Symbol.dispose` and `Symbol.asyncDispose` support (Moshe Atlow) #48518
net:
  * add autoSelectFamily global getter and setter (Paolo Insogna) #45777
url:
  * (SEMVER-MINOR) add value argument to has and delete methods (Sankalp Shubham) #47885

PR-URL: #49220
ruyadorno added a commit that referenced this pull request Sep 18, 2023
Notable changes:

build:
  * sync libuv header change (Jiawen Geng) #48078
crypto:
  * update root certificates to NSS 3.93 (Node.js GitHub Bot) #49341
  * update root certificates to NSS 3.90 (Node.js GitHub Bot) #48416
deps:
  * add missing thread-common.c in uv.gyp (Santiago Gimeno) #48078
  * upgrade to libuv 1.46.0 (Santiago Gimeno) #48078
  * upgrade to libuv 1.45.0 (Santiago Gimeno) #48078
doc:
  * add atlowChemi to collaborators (atlowChemi) #48757
  * add vmoroz to collaborators (Vladimir Morozov) #48527
  * add kvakil to collaborators (Keyhan Vakil) #48449
esm:
  * (SEMVER-MINOR) add `--import` flag (Moshe Atlow) #43942
events:
  * (SEMVER-MINOR) allow safely adding listener to abortSignal (Chemi Atlow) #48596
fs, stream:
  * initial `Symbol.dispose` and `Symbol.asyncDispose` support (Moshe Atlow) #48518
net:
  * add autoSelectFamily global getter and setter (Paolo Insogna) #45777
url:
  * (SEMVER-MINOR) add value argument to has and delete methods (Sankalp Shubham) #47885

PR-URL: #49220
alexfernandez pushed a commit to alexfernandez/node that referenced this pull request Nov 1, 2023
Notable changes:

build:
  * sync libuv header change (Jiawen Geng) nodejs#48078
crypto:
  * update root certificates to NSS 3.93 (Node.js GitHub Bot) nodejs#49341
  * update root certificates to NSS 3.90 (Node.js GitHub Bot) nodejs#48416
deps:
  * add missing thread-common.c in uv.gyp (Santiago Gimeno) nodejs#48078
  * upgrade to libuv 1.46.0 (Santiago Gimeno) nodejs#48078
  * upgrade to libuv 1.45.0 (Santiago Gimeno) nodejs#48078
doc:
  * add atlowChemi to collaborators (atlowChemi) nodejs#48757
  * add vmoroz to collaborators (Vladimir Morozov) nodejs#48527
  * add kvakil to collaborators (Keyhan Vakil) nodejs#48449
esm:
  * (SEMVER-MINOR) add `--import` flag (Moshe Atlow) nodejs#43942
events:
  * (SEMVER-MINOR) allow safely adding listener to abortSignal (Chemi Atlow) nodejs#48596
fs, stream:
  * initial `Symbol.dispose` and `Symbol.asyncDispose` support (Moshe Atlow) nodejs#48518
net:
  * add autoSelectFamily global getter and setter (Paolo Insogna) nodejs#45777
url:
  * (SEMVER-MINOR) add value argument to has and delete methods (Sankalp Shubham) nodejs#47885

PR-URL: nodejs#49220
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version. whatwg-url Issues and PRs related to the WHATWG URL implementation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add value argument to URLSearchParams's has() and delete()
9 participants