-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
src: implement whatwg's URLPattern spec #56452
Conversation
Review requested:
|
Can you elaborate? libuv is a C library so I don't think exceptions exist there, and I'm pretty sure V8 is built with exceptions disabled. |
My bad UV does not enable exceptions. Referencing v8.gyp file:
|
This is not really V8. It's a build-time executable (torque) used to generate code for V8 |
|
||
MaybeLocal<Value> URLPattern::Hash() const { | ||
auto context = env()->context(); | ||
return ToV8Value(context, url_pattern_.get_hash()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the key challenge here is that this will copy the string on every call. Any chance of memoizing the string once created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll follow up on a different PR for this
Can you also include a fairly simple benchmark? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #56452 +/- ##
==========================================
- Coverage 89.21% 89.18% -0.03%
==========================================
Files 663 665 +2
Lines 192001 192574 +573
Branches 36921 37046 +125
==========================================
+ Hits 171286 171749 +463
- Misses 13582 13635 +53
- Partials 7133 7190 +57
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t think this is a good pattern to land in Node.js. Specifically, a server using this will create one per route and iterate in a loop. This will be slow, specifically if you need to match the last of the list.
(This feedback was provided when URLPattern was standardized and essentially ignored).
For this to be useful, we would need to have a Node.js-specific API to organize these URLPattern in a radix prefix trie and actually do the matching all at once.
I can possibly be persuaded that we need this for Web platform compatibility, but it’s not that popular either (unlike fetch()).
@jasnell I’ll try to build this and get a benchmark going against the ecosystem routers. |
Right now, this pull-request does not pass WPT, and not at all optimized. Any benchmarks will not be beneficial. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't review the C++ but the parts I can look fine
|
||
Input can be a string or an object providing the individual URL parts. The | ||
object members can be any of `protocol`, `username`, `password`, `hostname`, | ||
`port`, `pathname`, `search`, `hash` or `baseURL`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`port`, `pathname`, `search`, `hash` or `baseURL`. | |
`port`, `pathname`, `search`, `hash`, or `baseURL`. |
|
||
Input can be a string or an object providing the individual URL parts. The | ||
object members can be any of `protocol`, `username`, `password`, `hostname`, | ||
`port`, `pathname`, `search`, `hash` or `baseURL`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`port`, `pathname`, `search`, `hash` or `baseURL`. | |
`port`, `pathname`, `search`, `hash`, or `baseURL`. |
constructor(input: Record<string, string> | string, options?: { ignoreCase: boolean }); | ||
constructor(input: Record<string, string> | string, baseUrl?: string, options?: { ignoreCase: boolean }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constructor(input: Record<string, string> | string, options?: { ignoreCase: boolean }); | |
constructor(input: Record<string, string> | string, baseUrl?: string, options?: { ignoreCase: boolean }); | |
constructor(input: Record<string, string> | string, options?: { ignoreCase?: boolean }); | |
constructor(input: Record<string, string> | string, baseUrl?: string, options?: { ignoreCase?: boolean }); |
since an empty options object is still permitted
This comment was marked as outdated.
This comment was marked as outdated.
@nodejs/tsc @nodejs/platform-smartos ... I can not justify the reasoning for waiting for smartOS build to succeed for more than 5.5 hours (https://ci.nodejs.org/job/node-test-commit-smartos/58956/nodes=smartos22-x64/) but here we are... The latest discussion didn't involve cases like this, we only had a discussion about flaky tests. Please ask yourselves, if you were a new contributor, would you still continue contributing to Node.js after waiting for 5 hours for CI to succeed? |
@anonrig As you know, this is currently being discussed in nodejs/build#4011 (which you opened), and there are proposals there to correct the issue. I'd like to keep the main discussion in that issue so that the conversation is all in one place. Thanks! |
@bahamat That discussion doesn't solve the frustration of this PR right now. Any suggestions on how to land this pull-request now? |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment has been minimized.
This comment has been minimized.
Landed in 44d2648...b78df6c |
Co-authored-by: Daniel Lemire <[email protected]> PR-URL: #56452 Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Jordan Harband <[email protected]> Reviewed-By: Stephen Belanger <[email protected]>
Co-authored-by: Daniel Lemire <[email protected]> PR-URL: #56452 Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Jordan Harband <[email protected]> Reviewed-By: Stephen Belanger <[email protected]>
Co-authored-by: Daniel Lemire <[email protected]> PR-URL: #56452 Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Jordan Harband <[email protected]> Reviewed-By: Stephen Belanger <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really qualified to review C++.
The rest LGTM. Nice job buddy!
Co-authored-by: Daniel Lemire <[email protected]> PR-URL: #56452 Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Jordan Harband <[email protected]> Reviewed-By: Stephen Belanger <[email protected]>
Co-authored-by: Daniel Lemire <[email protected]> PR-URL: #56452 Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Jordan Harband <[email protected]> Reviewed-By: Stephen Belanger <[email protected]>
Co-authored-by: Daniel Lemire <[email protected]> PR-URL: #56452 Reviewed-By: Daniel Lemire <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Jordan Harband <[email protected]> Reviewed-By: Stephen Belanger <[email protected]>
Notable changes: crypto: * (SEMVER-MINOR) support --use-system-ca on Windows (Joyee Cheung) #56833 * (SEMVER-MINOR) added support for reading certificates from macOS system store (Tim Jacomb) #56599 deps: * update timezone to 2025a (Node.js GitHub Bot) #56876 * (SEMVER-MINOR) update ada to v3.0.1 (Yagiz Nizipli) #56452 deps,tools: * (SEMVER-MINOR) add zstd 1.5.6 (Jan Krems) #52100 sqlite: * (SEMVER-MINOR) allow returning `ArrayBufferView`s from user-defined functions (René) #56790 src: * set signal inspector io thread name (RafaelGSS) #56416 * set thread name for main thread and v8 worker (RafaelGSS) #56416 * set worker thread name using worker.name (RafaelGSS) #56416 * use a default thread name for inspector (RafaelGSS) #56416 src, quic: * (SEMVER-MINOR) refine more of the quic implementation (James M Snell) #56328 test: * (SEMVER-MINOR) add WPT for URLPattern (Yagiz Nizipli) #56452 url: * (SEMVER-MINOR) add URLPattern implementation (Yagiz Nizipli) #56452 zlib: * (SEMVER-MINOR) add zstd support (Jan Krems) #52100 PR-URL: TODO
Notable changes: crypto: * (SEMVER-MINOR) support --use-system-ca on Windows (Joyee Cheung) #56833 * (SEMVER-MINOR) added support for reading certificates from macOS system store (Tim Jacomb) #56599 deps: * update timezone to 2025a (Node.js GitHub Bot) #56876 * (SEMVER-MINOR) update ada to v3.0.1 (Yagiz Nizipli) #56452 deps,tools: * (SEMVER-MINOR) add zstd 1.5.6 (Jan Krems) #52100 sqlite: * (SEMVER-MINOR) allow returning `ArrayBufferView`s from user-defined functions (René) #56790 src: * set signal inspector io thread name (RafaelGSS) #56416 * set thread name for main thread and v8 worker (RafaelGSS) #56416 * set worker thread name using worker.name (RafaelGSS) #56416 * use a default thread name for inspector (RafaelGSS) #56416 src, quic: * (SEMVER-MINOR) refine more of the quic implementation (James M Snell) #56328 test: * (SEMVER-MINOR) add WPT for URLPattern (Yagiz Nizipli) #56452 url: * (SEMVER-MINOR) add URLPattern implementation (Yagiz Nizipli) #56452 zlib: * (SEMVER-MINOR) add zstd support (Jan Krems) #52100 PR-URL: #57005
Notable changes: crypto: * (SEMVER-MINOR) support --use-system-ca on Windows (Joyee Cheung) #56833 * (SEMVER-MINOR) added support for reading certificates from macOS system store (Tim Jacomb) #56599 deps: * update timezone to 2025a (Node.js GitHub Bot) #56876 sqlite: * (SEMVER-MINOR) allow returning `ArrayBufferView`s from user-defined functions (René) #56790 src: * set signal inspector io thread name (RafaelGSS) #56416 * set thread name for main thread and v8 worker (RafaelGSS) #56416 * set worker thread name using worker.name (RafaelGSS) #56416 * use a default thread name for inspector (RafaelGSS) #56416 url: * (SEMVER-MINOR) add URLPattern implementation (Yagiz Nizipli) #56452 zlib: * (SEMVER-MINOR) add zstd support (Jan Krems) #52100 PR-URL: #57005
Notable changes: crypto: * (SEMVER-MINOR) support --use-system-ca on Windows (Joyee Cheung) #56833 * (SEMVER-MINOR) added support for reading certificates from macOS system store (Tim Jacomb) #56599 deps: * update timezone to 2025a (Node.js GitHub Bot) #56876 sqlite: * (SEMVER-MINOR) allow returning `ArrayBufferView`s from user-defined functions (René) #56790 src: * set signal inspector io thread name (RafaelGSS) #56416 * set thread name for main thread and v8 worker (RafaelGSS) #56416 * set worker thread name using worker.name (RafaelGSS) #56416 * use a default thread name for inspector (RafaelGSS) #56416 url: * (SEMVER-MINOR) add URLPattern implementation (Yagiz Nizipli) #56452 zlib: * (SEMVER-MINOR) add zstd support (Jan Krems) #52100 PR-URL: #57005
Co-authored-by: Daniel Lemire (@lemire)
Notes:
TODOs
cc @nodejs/cpp-reviewers
Fixes #40844