Skip to content

fix(experimental): match root paths with multiple optional params - #2830

Merged
posva merged 1 commit into
mainfrom
fix/multiple-optional
Oct 8, 2026
Merged

posva merged 1 commit into
mainfrom
fix/multiple-optional

Conversation

@posva

@posva posva commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Fix matching and building root paths with only optional params, with integration tests for generated matchers.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected route matching and URL generation for the root path when trailing slashes are involved.
    • Improved handling of routes with optional path segments, including when a trailing slash is accepted.

@netlify

netlify Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for vue-router canceled.

Name Link
🔨 Latest commit 4633dd1
🔍 Latest deploy log https://app.netlify.com/projects/vue-router/deploys/6ac7a244c3961a0008c80d76

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: vuejs/router/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b4f90c3f-4454-4f6f-9b98-0323fc888e4d
📥 Commits

Reviewing files that changed from the base of the PR and between 8c91f98 and 4633dd1.

📒 Files selected for processing (4)
  • packages/router/src/experimental/route-resolver/generated-matcher.spec.ts
  • packages/router/src/experimental/route-resolver/matchers/matcher-pattern.spec.ts
  • packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts
  • packages/router/src/unplugin/core/tree.ts
💤 Files with no reviewable changes (1)
  • packages/router/src/experimental/route-resolver/matchers/matcher-pattern.spec.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The route-expression generator and matcher now handle root paths for optional routes. A new generated matcher specification covers matching and building across parameter patterns, while dynamic matcher tests are removed from the existing specification.

Changes

Generated route matcher behavior

Layer / File(s) Summary
Optional route root-path handling
packages/router/src/unplugin/core/tree.ts, packages/router/src/experimental/route-resolver/matchers/matcher-pattern.ts
The route-expression generator recognizes routes made only of optional parameters and adds an optional slash when applicable. The matcher accepts / under trailing-slash checks and builds / when trimming would otherwise return an empty path.
Generated matcher tests
packages/router/src/experimental/route-resolver/generated-matcher.spec.ts, packages/router/src/experimental/route-resolver/matchers/matcher-pattern.spec.ts
Adds generated matcher tests for parameter patterns, encoding, route groups, and matching/building edge cases. Removes dynamic matching and building tests from the existing matcher specification.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 4633d

The root-path behavior is consistent across matching and building, and no merge-blocking issue remains after normal checks.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: fixing root-path matching with multiple optional parameters. This matches the stated objectives and test additions.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@pkg-pr-new

pkg-pr-new Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

pnpm add https://pkg.pr.new/vue-router@2830
npm i https://pkg.pr.new/vue-router@2830
yarn add https://pkg.pr.new/vue-router@2830.tgz

commit: 4633dd1

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.25%. Comparing base (596d481) to head (4633dd1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2830      +/-   ##
==========================================
+ Coverage   88.07%   88.25%   +0.18%     
==========================================
  Files          78       78              
  Lines        6289     6303      +14     
  Branches     2041     2069      +28     
==========================================
+ Hits         5539     5563      +24     
+ Misses        661      651      -10     
  Partials       89       89              

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

@posva
posva force-pushed the fix/multiple-optional branch from 17d70c9 to 381140d Compare October 8, 2026 13:55
@posva
posva force-pushed the fix/multiple-optional branch from 381140d to 4633dd1 Compare October 8, 2026 14:01
@posva
posva merged commit 04016f6 into main Oct 8, 2026
11 checks passed
@posva
posva deleted the fix/multiple-optional branch October 8, 2026 14:11
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.

1 participant