Skip to content

fix(matcher): finalize param token before processing escaped colon#2654

Merged
posva merged 3 commits into
vuejs:mainfrom
babu-ch:fix/colon
Apr 22, 2026
Merged

fix(matcher): finalize param token before processing escaped colon#2654
posva merged 3 commits into
vuejs:mainfrom
babu-ch:fix/colon

Conversation

@babu-ch

@babu-ch babu-ch commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

fixes #2517

Summary by CodeRabbit

  • Bug Fixes

    • Improved parsing of escaped special characters in route patterns so characters (e.g., +, -, :) following parameters are treated as literal static text rather than modifiers.
  • Tests

    • Added extensive tests verifying tokenizer and matcher behavior for escape sequences, ensuring literal characters and parameter boundaries are preserved in URL matching.

@netlify

netlify Bot commented Mar 11, 2026

Copy link
Copy Markdown

Deploy Preview for vue-router canceled.

Name Link
🔨 Latest commit 7775f67
🔍 Latest deploy log https://app.netlify.com/projects/vue-router/deploys/69e8ccb55632520008f9f023

@coderabbitai

coderabbitai Bot commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5629b0fd-5acc-4e1e-b535-b9467ea59e56

📥 Commits

Reviewing files that changed from the base of the PR and between c57b7d2 and 7775f67.

📒 Files selected for processing (1)
  • packages/router/__tests__/matcher/pathParser.spec.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/router/tests/matcher/pathParser.spec.ts

📝 Walkthrough

Walkthrough

Confines backslash escape handling to the Static tokenizer state so escapes following parameters are treated as literal static text; adds tests verifying escaped characters (notably \:) after params tokenize and parse into correct static tokens and maintain proper parameter boundaries and matching.

Changes

Cohort / File(s) Summary
Tokenizer Implementation
packages/router/src/matcher/pathTokenizer.ts
Removed the top-level global handling of \ and instead handle backslash escapes only within the TokenizerState.Static branch, preventing escape logic from affecting Param and ParamRegExp parsing.
Parser Tests
packages/router/__tests__/matcher/pathParser.spec.ts
Added extensive tokenizer and parser assertions (~144 lines) that validate escaped characters after parameters (e.g., \\-, \\+, \\:, escaped colons between params), ensuring escapes produce Static tokens and that resulting parsers match URLs with the literal characters and preserve parameter names/values.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I hopped through tokens, sniffed a trace,
A sneaky backslash hid its face.
Now Static guards the little sign,
Colons stay put, params align.
Tests applaud — a tidy parse! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the core fix: finalizing param tokens before processing escaped colons, which matches the main objective to resolve parameter mis-parsing when followed by escaped colons.
Linked Issues check ✅ Passed The PR adds comprehensive test coverage for escaped colon handling and modifies the tokenizer to route backslash handling through Static state only, directly addressing issue #2517's requirement that parameters followed by escaped colons must be correctly parsed.
Out of Scope Changes check ✅ Passed All changes are focused on fixing escaped colon parsing in the matcher: test coverage validates the fix, and the tokenizer modification ensures parameters are finalized before escaped colons are processed.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new

pkg-pr-new Bot commented Mar 11, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/vue-router@2654

commit: 7775f67

@codecov

codecov Bot commented Mar 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.92%. Comparing base (f6923a5) to head (7775f67).
⚠️ Report is 32 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2654      +/-   ##
==========================================
+ Coverage   85.66%   85.92%   +0.26%     
==========================================
  Files          86       88       +2     
  Lines       10007    10076      +69     
  Branches     2289     2315      +26     
==========================================
+ Hits         8572     8658      +86     
+ Misses       1422     1407      -15     
+ Partials       13       11       -2     

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

babu-ch and others added 2 commits April 22, 2026 15:05
The pre-switch block had grown three distinct behaviors depending on state
(ignore in ParamRegExp, finalize-then-escape in Param/ParamRegExpEnd, plain
escape in Static). Moving the transition into the Static case lets Param
and ParamRegExpEnd reuse their existing consume-and-step-back logic — \\
simply falls through, finalizes the param, and gets reprocessed in Static.
@posva posva merged commit 20521b0 into vuejs:main Apr 22, 2026
10 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.

Parameters followed by an escaped colon are mis-parsed

2 participants