Repository navigation
Conversation
|
Review requested:
|
|
The
notable-change
Please suggest a text for the release notes if you'd like to include a more detailed summary, then proceed to update the PR description with the text or a link to the notable change suggested text comment. Otherwise, the commit will be placed in the Other Notable Changes section. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #67807 +/- ##
==========================================
+ Coverage 90.50% 90.51% +0.01%
==========================================
Files 805 805
Lines 285818 286190 +372
Branches 55182 55269 +87
==========================================
+ Hits 258666 259035 +369
+ Misses 17251 17229 -22
- Partials 9901 9926 +25
🚀 New features to boost your workflow:
|
Shared-library CI builds Node against nixpkgs ada 4.0.0, which does not provide ada::url_pattern_list. The vendored copy is ada 4.1.1, so override the shared ada package to that release until the nixpkgs pin includes it. Refs: nodejs#67807 Assisted-by: Cursor Grok 4.7 Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com> Co-authored-by: Yagiz Nizipli <anonrig@users.noreply.github.com>
Version changes
|
Mark util.URLPatternList as stability 1.0 (early development) and note that it is not a standard API, and that it is not yet clear whether it will become one. Refs: nodejs#67807 Assisted-by: Cursor Grok 4.7 Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com> Co-authored-by: Yagiz Nizipli <anonrig@users.noreply.github.com>
| util.types.isWeakSet(new WeakSet()); // Returns true | ||
| ``` | ||
| ## Class: `util.URLPatternList` |
There was a problem hiding this comment.
Why util when URLPattern is on url?
There was a problem hiding this comment.
Oh you're right. I misremembered.
Version changes
|
| // URLPatternList is specified in terms of URLPattern: exec() returns the | ||
| // URLPattern#exec() result of the first pattern in the list that matches, and | ||
| // test() returns whether any pattern matches. This test checks that against | ||
| // every case of the URLPattern web-platform-tests. |
There was a problem hiding this comment.
The wpt in the name here is confusing. Is this ported from an actual wpt? It's not clear.
Export URLPatternList from node:url, next to URLPattern, and keep it off the global object. Move the tests, benchmark import, and docs with it. Refs: nodejs#67807 Assisted-by: Cursor Grok 4.7 Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com> Co-authored-by: Yagiz Nizipli <anonrig@users.noreply.github.com>
Version changes
|
Add url.URLPatternList, exported from node:url and not from node:util or globalThis. It matches a URL against an ordered list of URLPattern objects and reports the first pattern that matches. The API is stability 1.0 (early development). It is not a standard API, and it is not yet clear whether it will become one. The list is implemented in C++ on the url_pattern binding and backed by ada::url_pattern_list. The URLPattern constructor template is cached on IsolateData. The first construction emits an ExperimentalWarning. Add benchmark/url/urlpatternlist-exec.js and the test/parallel/test-urlpatternlist*.js tests. Bump the Nix shared ada package to 4.1.1 so shared-library builds provide ada::url_pattern_list. Refs: whatwg/urlpattern#166 Refs: nodejs#67807 Assisted-by: Cursor Grok 4.7 Signed-off-by: Yagiz Nizipli <yagiz@nizipli.com> Co-authored-by: Yagiz Nizipli <anonrig@users.noreply.github.com>
8918477 to
90a6fc9
Compare
Version changes
|
Credit to @FranciscoThiesen, who wrote the C++ implementation and contributed it to Ada.
This adds
url.URLPatternList, an experimental implementation of theURLPatternListinterface proposed in whatwg/urlpattern#166,built on the
ada::url_pattern_listAPI from the Ada 4.1.1 update.Behavior
This follows the spec PR:
new URLPatternList(patterns)takes an iterable ofURLPatternobjects. Itthrows a
TypeErrorif a value is not aURLPattern, if the sameURLPatternappears more than once, or if the list is empty. Strings,URLPatternInitdictionaries and options are not accepted, because the IDLis
constructor(sequence<URLPattern> patterns). Each pattern keeps its ownignoreCase.exec(input = {}, baseURL)returns theURLPattern#exec()result of thefirst pattern in list order that matches, plus a
patternmember, ornull.test(input = {}, baseURL)returns whether any pattern matches.ExperimentalWarning. Loading or importingnode:urldoes not.Implementation
ada::url_pattern_listmatches pathnames only and reports the most specificroute. The spec matches every component and returns the first match in list
order. So the list does not return Ada's route. It uses the index only to skip
work:
ada::url_pattern::match()does,and the patterns are matched with
ada::url_pattern::test_components().patterns outside the index are tested.
it need to be tested, and
test()returnstrueright away.compiles pathnames. Patterns with a non-special scheme, or with a different
ignoreCasethan the first indexed pattern, are always tested.Like
URLPattern, the class is implemented entirely in theurl_patternbinding, including the
sequence<URLPattern>conversion, andnode:urlexports the native class (it is not exposed on
globalThis). TheURLPatternconstructor template is now cached in
IsolateData, asSocketAddressdoes,so that the list can check that its values are
URLPatternobjects.benchmark/url/urlpatternlist-exec.jscompares the list with theURLPattern#exec()loop that the spec describes. With 1000 routes:URLPatternListURLPatternloopBecause the spec uses list order, a match late in the list still needs a linear
scan. Whether the order should stay as it is or become a specificity order
(what Ada's list implements) is still open in the spec PR.
Tests
test-urlpatternlist.js: interface shape, constructor conversion anderrors, list order, matching on every component, inputs and base URLs, mixed
ignoreCase, non-special schemes, regexp groups, non-ASCII input, large listsand long inputs, brand checks, and a seeded comparison with the spec's loop.
test-urlpatternlist-wpt.js: every URLPattern WPT case, as a list of onepattern and inside a list of all the WPT patterns, compared with the spec's
loop.
test-urlpatternlist-experimental-warning.jsandtest-urlpatternlist-worker.js.AI assistance
This change was written with the help of Cursor (Claude Opus 5.5). It was
verified locally on this branch with:
make -j38 test: tooltest, cctest (317 tests) and 7,623 JS tests pass. The68 other JS tests fail only because the build machine sets
HTTP_PROXY,HTTPS_PROXY,NODE_DISABLE_COMPILE_CACHE,FORCE_COLORandNO_COLOR,and they pass with those variables unset.
make lint,make doc-only, andgit-clang-formatagainstmain.indexing patterns with non-special schemes, and skipping the patterns that
the index does not cover) makes the new tests fail.