mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #401] [MERGED] fix: Reject non-terminal catch-all routes in pages and app routers #544
Labels
No labels
enhancement
enhancement
good first issue
help wanted
nextjs-tracking
nextjs-tracking
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/vinext#544
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/cloudflare/vinext/pull/401
Author: @JaredStowell
Created: 3/10/2026
Status: ✅ Merged
Merged: 3/10/2026
Merged by: @james-elicx
Base:
main← Head:jstowell/fix-nonterminal-catchall-routes📝 Commits (8)
ce6f6a4Fix catch-all route overmatching7cfb368Fix non-terminal slot routesf660f15Fix malformed slot route discovery11ad0a1Add validation for intercept catch-e726bdfFix intercepting route catch-alls52a9d6dbonk704bcc2Fix routing test route literals for typecheckbe71f21Fix app route matcher test fixtures📊 Changes
7 files changed (+484 additions, -100 deletions)
View changed files
📝
packages/vinext/src/entries/app-rsc-entry.ts(+2 -0)📝
packages/vinext/src/entries/pages-server-entry.ts(+2 -0)📝
packages/vinext/src/routing/app-router.ts(+63 -92)📝
packages/vinext/src/routing/pages-router.ts(+18 -7)📝
tests/__snapshots__/entry-templates.test.ts.snap(+14 -0)📝
tests/entry-templates.test.ts(+5 -0)📝
tests/routing.test.ts(+380 -1)📄 Description
Fixes a routing bug where non-terminal catch-all segments were accepted during route discovery and then overmatched at runtime.
Before this change, paths like
pages/[...slug]/edit/index.tsxwere converted into the invalid internal pattern/:slug+/edit, and the matcher would return as soon as it saw:slug+or:slug*. That caused the route to match URLs it should never match, including both/fooand/foo/edit.This change fixes that in both the Pages Router and App Router.
What changed
/:slug+/editand/:slug*/editdo not overmatchDetails
Pages Router
fileToRoute()now rejects[...param]and[[...param]]unless they are terminalmatchPattern()now treats non-terminal:param+and:param*as invalid instead of returning earlyApp Router
fileToAppRoute()now rejects non-terminal catch-all segments based on visible URL segments, not raw filesystem depthapp/[...slug]/(admin)/page.tsxstill resolve to valid/:slug+matchPattern()now rejects malformed non-terminal internal catch-all patternsTests
Added regression coverage for:
/:slug+/edit/:slug*/edit🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.