GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: implement whatwg's URLPattern spec by anonrig · Pull Request #56452 · nodejs/node

Conversation

@anonrig

@anonrig anonrig commented Jan 3, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Co-authored-by: Daniel Lemire (@lemire)

Notes:

  • Ada now requires C++20
  • URLPattern is exposed through node:url module

TODOs

  • Removed exception flag requirement
  • Pass all web-platform tests
  • Release Ada v3 before landing this PR
  • Make sure to split all changes to multiple commits
  • Add @lemire as co-author to all commits
  • Land upstream pull-request implement URLPattern ada-url/ada#785
  • Add documentation for global and node:url module declarations.

cc @nodejs/cpp-reviewers

Fixes #40844

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss, jimmywarting, infodusha, dnalborczyk, and TheOneTheOnlyJJ reacted with thumbs up emoji bricss, jimmywarting, CarlosEduR, infodusha, dnalborczyk, and TheOneTheOnlyJJ reacted with hooray emoji bricss, jimmywarting, infodusha, dnalborczyk, TheOneTheOnlyJJ, and KylePDavis reacted with heart emoji bricss, jimmywarting, infodusha, dnalborczyk, and TheOneTheOnlyJJ reacted with rocket emoji zloirock, bricss, and TheOneTheOnlyJJ reacted with eyes emoji
All reactions
  • 👍 5 reactions
  • 🎉 6 reactions
  • ❤️ 6 reactions
  • 🚀 5 reactions
  • 👀 3 reactions
@anonrig
anonrig requested review from RafaelGSS and jasnell January 3, 2025 16:07
@nodejs-github-bot

nodejs-github-bot commented Jan 3, 2025

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/gyp
  • @nodejs/security-wg
  • @nodejs/startup
  • @nodejs/url
  • @nodejs/web-standards
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. labels Jan 3, 2025
anonrig
anonrig commented Jan 3, 2025
View reviewed changes
Comment thread test/parallel/test-shadow-realm-globals.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@targos targos added the semver-major PRs that contain breaking changes and should be released in the next major version. label Jan 3, 2025
@anonrig anonrig added macos Issues and PRs related to the macOS platform. blocked PRs that are blocked by other issues or PRs. build-agenda Issues and PRs to discuss during Build Working Group meetings. labels Jan 3, 2025
@targos

targos commented Jan 3, 2025

Copy link
Copy Markdown
Member

Ada now enables exceptions just like UV and V8

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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anonrig

anonrig commented Jan 3, 2025

Copy link
Copy Markdown
Member Author

Ada now enables exceptions just like UV and V8

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:

{
  'target_name': 'torque_base',
  'type': 'static_library',
  'toolsets': ['host', 'target'],
  'sources': [
    '<!@pymod_do_main(GN-scraper "<(V8_ROOT)/BUILD.gn"  "\\"torque_base.*?sources = ")',
  ],
  'dependencies': [
    'v8_shared_internal_headers',
    'v8_libbase',
  ],
  'defines!': [
    '_HAS_EXCEPTIONS=0',
    'BUILDING_V8_SHARED=1',
  ],
  'cflags_cc!': ['-fno-exceptions'],
  'cflags_cc': ['-fexceptions'],
  'xcode_settings': {
    'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',  # -fexceptions
  },
  'msvs_settings': {
    'VCCLCompilerTool': {
      'RuntimeTypeInfo': 'true',
      'ExceptionHandling': 1,
    },
  },
}
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@targos

targos commented Jan 3, 2025

Copy link
Copy Markdown
Member

This is not really V8. It's a build-time executable (torque) used to generate code for V8

anonrig reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anonrig
anonrig requested a review from Qard January 3, 2025 16:27
jasnell
jasnell reviewed Jan 3, 2025
View reviewed changes
Comment thread src/node_url_pattern.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell reviewed Jan 3, 2025
View reviewed changes
Comment thread src/node_url_pattern.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell reviewed Jan 3, 2025
View reviewed changes
Comment thread src/node_url_pattern.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell reviewed Jan 3, 2025
View reviewed changes
Comment thread src/node_url_pattern.cc Outdated

@jasnell jasnell Jan 3, 2025

Copy link
Copy Markdown
Member

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@anonrig anonrig Jan 30, 2025

Copy link
Copy Markdown
Member Author

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
jasnell
jasnell reviewed Jan 3, 2025
View reviewed changes
Comment thread src/node_url_pattern.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell reviewed Jan 3, 2025
View reviewed changes
Comment thread lib/internal/url.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell reviewed Jan 3, 2025
View reviewed changes
Comment thread src/node_url_pattern.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell reviewed Jan 3, 2025
View reviewed changes
Comment thread src/node_url_pattern.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell reviewed Jan 3, 2025
View reviewed changes
Comment thread src/node_url_pattern.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell reviewed Jan 3, 2025
View reviewed changes
Comment thread src/node_url_pattern.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

@jasnell

jasnell commented Jan 3, 2025

Copy link
Copy Markdown
Member

Can you also include a fairly simple benchmark?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codecov

codecov Bot commented Jan 3, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 78.64769% with 120 lines in your changes missing coverage. Please review.

Project coverage is 89.18%. Comparing base (f2001e3) to head (49d1fd7).
Report is 583 commits behind head on main.

Files with missing lines Patch % Lines
src/node_url_pattern.cc 78.77% 58 Missing and 60 partials ⚠️
src/node_url_pattern.h 0.00% 2 Missing ⚠️
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     
Files with missing lines Coverage Δ
lib/internal/url.js 97.55% <100.00%> (-0.13%) ⬇️
lib/url.js 100.00% <100.00%> (ø)
src/node_binding.cc 83.66% <ø> (ø)
src/node_errors.h 85.00% <ø> (ø)
src/node_external_reference.h 100.00% <ø> (ø)
src/node_url_pattern.h 0.00% <0.00%> (ø)
src/node_url_pattern.cc 78.77% <78.77%> (ø)

... and 31 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

lukeed
lukeed reviewed Jan 3, 2025
View reviewed changes
Comment thread src/node_url_pattern.cc Resolved

Uh oh!

There was an error while loading. Please reload this page.

mcollina
mcollina previously requested changes Jan 3, 2025
View reviewed changes

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

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()).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

carburo reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
@mcollina

mcollina commented Jan 3, 2025

Copy link
Copy Markdown
Member

@jasnell I’ll try to build this and get a benchmark going against the ecosystem routers.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anonrig

anonrig commented Jan 3, 2025

Copy link
Copy Markdown
Member Author

@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.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

anonrig and others added 2 commits January 30, 2025 18:56
@anonrig @lemire
url: add URLPattern implementation
630c5d8
Co-authored-by: Daniel Lemire <[email protected]>
@anonrig @lemire
test: add WPT for URLPattern
a0b10cd
Co-authored-by: Daniel Lemire <[email protected]>
@nodejs-github-bot

This comment was marked as outdated.

Sign in to view
@anonrig

anonrig commented Jan 31, 2025

Copy link
Copy Markdown
Member Author

@nodejs/cpp-reviewers @nodejs/TSC appreciate it if you could review

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes Jan 31, 2025
View reviewed changes
@anonrig
fixup! url: add URLPattern implementation
49d1fd7
@nodejs-github-bot

This comment was marked as outdated.

Sign in to view
cjihrig
cjihrig approved these changes Jan 31, 2025
View reviewed changes
benjamingr
benjamingr reviewed Jan 31, 2025
View reviewed changes
Comment thread doc/api/url.md

The constructor can throw a `TypeError` to indicate parsing failure.

#### `new URLPattern(objg[, baseURL][, options])`

@benjamingr benjamingr Jan 31, 2025

Copy link
Copy Markdown
Member

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.

Suggested change
#### `new URLPattern(objg[, baseURL][, options])`
#### `new URLPattern(obj[, baseURL][, options])`

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ljharb reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

@anonrig anonrig Jan 31, 2025

Copy link
Copy Markdown
Member Author

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.

You have the eyes of an eagle.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
benjamingr
benjamingr approved these changes Jan 31, 2025
View reviewed changes
ljharb
ljharb approved these changes Jan 31, 2025
View reviewed changes

@ljharb ljharb left a comment

Copy link
Copy Markdown
Member

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread doc/api/url.md

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`.

@ljharb ljharb Jan 31, 2025

Copy link
Copy Markdown
Member

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.

Suggested change
`port`, `pathname`, `search`, `hash` or `baseURL`.
`port`, `pathname`, `search`, `hash`, or `baseURL`.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread doc/api/url.md

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`.

@ljharb ljharb Jan 31, 2025

Copy link
Copy Markdown
Member

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.

Suggested change
`port`, `pathname`, `search`, `hash` or `baseURL`.
`port`, `pathname`, `search`, `hash`, or `baseURL`.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread typings/internalBinding/url_pattern.d.ts
Comment on lines +11 to +12
constructor(input: Record<string, string> | string, options?: { ignoreCase: boolean });
constructor(input: Record<string, string> | string, baseUrl?: string, options?: { ignoreCase: boolean });

@ljharb ljharb Jan 31, 2025

Copy link
Copy Markdown
Member

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.

Suggested change
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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Qard
Qard approved these changes Jan 31, 2025
View reviewed changes
@nodejs-github-bot

This comment was marked as outdated.

Sign in to view
@anonrig anonrig mentioned this pull request Jan 31, 2025
smartOS builds are taking more than 6 hours nodejs/build#4011
Closed
@anonrig

anonrig commented Jan 31, 2025

Copy link
Copy Markdown
Member Author

@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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bahamat

bahamat commented Jan 31, 2025

Copy link
Copy Markdown

@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!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@anonrig

anonrig commented Jan 31, 2025

Copy link
Copy Markdown
Member Author

@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?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

This comment was marked as outdated.

Sign in to view
@anonrig

This comment was marked as outdated.

Sign in to view
@nodejs-github-bot

nodejs-github-bot commented Jan 31, 2025

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/64891/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Feb 1, 2025

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/64892/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bahamat

This comment has been minimized.

Sign in to view
@nodejs-github-bot

nodejs-github-bot commented Feb 1, 2025

Copy link
Copy Markdown
Collaborator

Landed in 44d2648...b78df6c

bricss, niksy, TheOneTheOnlyJJ, and Qard reacted with hooray emoji
All reactions
  • 🎉 4 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ShogunPanda
ShogunPanda reviewed Feb 1, 2025
View reviewed changes

@ShogunPanda ShogunPanda left a comment

Copy link
Copy Markdown
Contributor

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!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@zloirock zloirock mentioned this pull request Feb 4, 2025
URLPattern zloirock/core-js#1011
Open
@github-actions github-actions Bot mentioned this pull request Feb 11, 2025
2025-02-13, Version 23.8.0 (Current) #57005
Merged
@smartie2037 smartie2037 mentioned this pull request Feb 19, 2025
Add MemeCore Chain ethereum-lists/chains#6837
Merged
@RafaelGSS RafaelGSS mentioned this pull request Apr 11, 2025
2025-04-23, Version 22.15.0 'Jod' (LTS), @UlisesGascon prepared by @RafaelGSS #57840
Merged
@AbhiPrasad AbhiPrasad mentioned this pull request Apr 14, 2025
Node 24 Support getsentry/sentry-javascript#16058
Closed
@richardlau richardlau mentioned this pull request Sep 19, 2025
doc: fix a missing link in the errors page #59427
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@ShogunPanda ShogunPanda ShogunPanda left review comments
@addaleax addaleax addaleax left review comments
@legendecas legendecas legendecas left review comments
@ljharb ljharb ljharb approved these changes
@Qard Qard Qard approved these changes
@jasnell jasnell jasnell approved these changes
@benjamingr benjamingr benjamingr approved these changes
@cjihrig cjihrig cjihrig approved these changes
@RafaelGSS RafaelGSS Awaiting requested review from RafaelGSS
@joyeecheung joyeecheung Awaiting requested review from joyeecheung
@mcollina mcollina Awaiting requested review from mcollina
@ronag ronag Awaiting requested review from ronag
@atlowChemi atlowChemi Awaiting requested review from atlowChemi
@lemire lemire Awaiting requested review from lemire
+1 more reviewer
@lukeed lukeed lukeed left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-rebase PRs the Commit Queue should land as multiple self-contained commits. dont-land-on-v22.x PRs that should not land on the v22.x-staging branch and should not be released in v22.x. lib / src Issues and PRs involving general changes in the lib/ or src/ directories. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. 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

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

implement URLPattern

Uh oh!

There was an error while loading. Please reload this page.

19 participants

@anonrig @nodejs-github-bot @targos @jasnell @mcollina @marco-ippolito @mon-jai @domenic @lemire @StefanStojanovic @bahamat @ljharb @ShogunPanda @Qard @addaleax @benjamingr @cjihrig @ronag @lukeed
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.