Skip to content

keep query and fragment delimiter in canonicalize search and hash - #1171

Merged
anonrig merged 1 commit into
ada-url:mainfrom
Arawoof06:search-hash-delimiter
Jul 9, 2026
Merged

anonrig merged 1 commit into
ada-url:mainfrom
Arawoof06:search-hash-delimiter

Conversation

@Arawoof06

Copy link
Copy Markdown
Contributor

canonicalize_search and canonicalize_hash strip a leading "?"/"#", but per the URLPattern spec that single delimiter is removed by process a search / process a hash, while these encoders run the URL parser in query state / fragment state where "?" and "#" are ordinary code points. The extra strip drops an escaped literal, so URLPattern({search: "\?x"}) compiles a pattern that matches a search of "x" instead of "?x", and canonicalize_search("?x") returns "x" rather than "?x". The effect was hidden for base-URL inheritance because url_pattern_init::process passed get_search()/get_hash() with their delimiters straight into process a base URL string, so the two strips cancelled. This drops the strip from both encoders and feeds the raw query/fragment (leading delimiter removed) when inheriting from a base URL, matching the spec's "baseURL's query" / "baseURL's fragment". Added a regression test; the full WPT urlpattern suite stays green.

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 12.50000% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.79%. Comparing base (5b94add) to head (6aa91ce).

Files with missing lines Patch % Lines
src/url_pattern.cpp 16.66% 0 Missing and 5 partials ⚠️
src/url_pattern_helpers.cpp 0.00% 0 Missing and 2 partials ⚠️

❌ Your patch check has failed because the patch coverage (12.50%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1171      +/-   ##
==========================================
- Coverage   59.87%   59.79%   -0.09%     
==========================================
  Files          37       37              
  Lines        6121     6121              
  Branches     2974     2978       +4     
==========================================
- Hits         3665     3660       -5     
- Misses        617      618       +1     
- Partials     1839     1843       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anonrig
anonrig merged commit 761db09 into ada-url:main Jul 9, 2026
53 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants