Skip to content

url: refactor URLPattern::{Exec,Test}#63667

Open
tniessen wants to merge 1 commit into
nodejs:mainfrom
tniessen:urlpattern-dedup
Open

url: refactor URLPattern::{Exec,Test}#63667
tniessen wants to merge 1 commit into
nodejs:mainfrom
tniessen:urlpattern-dedup

Conversation

@tniessen
Copy link
Copy Markdown
Member

Refactor these URLPattern methods and extract common logic into a helper function, reducing code duplication.

Refactor these `URLPattern` methods and extract common logic into a
helper function, reducing code duplication.

Signed-off-by: Tobias Nießen <tniessen@tnie.de>
@tniessen tniessen added c++ Issues and PRs that require attention from people who are familiar with C++. whatwg-urlpattern labels May 30, 2026
@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 30, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

❌ Patch coverage is 93.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.33%. Comparing base (79def6d) to head (b3edf4e).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/node_url_pattern.cc 93.75% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63667      +/-   ##
==========================================
+ Coverage   90.32%   90.33%   +0.01%     
==========================================
  Files         732      732              
  Lines      236435   236428       -7     
  Branches    44527    44519       -8     
==========================================
+ Hits       213563   213589      +26     
+ Misses      14589    14541      -48     
- Partials     8283     8298      +15     
Files with missing lines Coverage Δ
src/node_url_pattern.h 0.00% <ø> (ø)
src/node_url_pattern.cc 83.41% <93.75%> (-0.31%) ⬇️

... and 34 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.

Comment thread src/node_url_pattern.cc
THROW_ERR_OPERATION_FAILED(env, "Failed to exec URLPattern");
return;
R result{};
if (((url_pattern->*func)(env, input, baseURL_opt).*to_r)(&result)) {
Copy link
Copy Markdown
Member

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 readable at all.

Comment thread src/node_url_pattern.cc
template <typename R,
typename M,
bool (M::*to_r)(R*) const,
M (URLPattern::*func)(Environment*,
Copy link
Copy Markdown
Member

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 solution. Yes you're reducing code duplication but at what cost? reducing readability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ Issues and PRs that require attention from people who are familiar with C++. needs-ci PRs that need a full CI run. whatwg-url Issues and PRs related to the WHATWG URL implementation. whatwg-urlpattern

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants