Repository navigation
fix(routing): match base path for named catch-all routes - #4812
Merged
Merged
Conversation
Scan `[...name]` as `:name(.*)` instead of `**:name`, which in rou3 requires at least one segment.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 15
✨ Finishing Touches
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. Comment |
commit: |
pi0
approved these changes
Oct 17, 2026
1 of 8 tasks
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #4808 (see also #1242)
File routes like
routes/test/[...path].tswere scanned as/test/**:path. In rou3,**:nameneeds at least one segment, so/testand/test/returned 404, while the unnamedroutes/test/[...].ts(/test/**) matched them.Named catch-alls are now scanned as
/test/:path(.*), which matches zero or more segments:/testgives nopathparam (undefined)/test/givesparams.path === ""/test/a/bgivesparams.path === "a/b"(same as before)A sibling
routes/test/index.tsstill wins for/test. The compiled router is as fast as or a bit faster than before with this pattern.Code that read the old
**:nameform now handles the new one too:[...name]{name}[...name](they used to come out as[...][name])routes/[...slug].tsas a catch-allBehavior change:
/test) now hit that handler instead of returning 404, so a handler that assumes the param is always set will now seeundefinedor"".routes/[...slug].tsandroutes/docs/[...a].ts,/docsused to go to the root catch-all withslug="docs". It now goes todocs/[...a].tswithaundefined. In the same way,/docs/guidemoves fromdocs/[...a].tstodocs/guide/[...b].tswhen both exist.routes/[...slug].tsnow also matches/withslug="". With a renderer,/now reaches that catch-all first instead of returning 404 from it.http.routetrace attribute (and the span name) for these routes changes from/x/**:slugto/x/:slug(.*).[...slug].json.tsandv-[...slug].tsused to fail the build, because rou3 rejected**:slug.jsonandv-**:slug. They now build as:slug(.*).jsonandv-:slug(.*).Tests: I added fixture routes
api/catch-all/[...slug].tsandapi/catch-all-index/{index,[...slug]}.tswith assertions intest/tests.ts(these fail on main with a 404), plus an OpenAPI check and unit cases for the Vercel dest and the chunk names. Vercel snapshots are updated: thesrcregexes now also match the base path.🤖 Generated with AI assistant