mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #1054] [MERGED] fix(routing): accept any non-] chars in dynamic segment names (Next.js parity) #1051
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#1051
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/1054
Author: @NathanDrake2406
Created: 5/4/2026
Status: ✅ Merged
Merged: 5/5/2026
Merged by: @james-elicx
Base:
main← Head:fix/routing-dynamic-segments-and-precedence📝 Commits (1)
281dafdfix(routing): accept any non-] chars in dynamic segment names (Next.js parity)📊 Changes
9 files changed (+178 additions, -19 deletions)
View changed files
📝
packages/vinext/src/entries/pages-server-entry.ts(+6 -3)📝
packages/vinext/src/routing/app-route-graph.ts(+11 -3)📝
packages/vinext/src/routing/pages-router.ts(+12 -6)📝
packages/vinext/src/routing/route-validation.ts(+6 -3)📝
packages/vinext/src/routing/utils.ts(+4 -1)📝
packages/vinext/src/shims/router.ts(+4 -3)📝
tests/app-route-graph.test.ts(+50 -0)📝
tests/route-sorting.test.ts(+16 -0)📝
tests/routing.test.ts(+69 -0)📄 Description
Summary
Aligns vinext's dynamic segment name parsing with Next.js
PARAMETER_PATTERN, which accepts any non-\]characters inside brackets. vinext was restricting param names to[\w-]+, silently treating valid Next.js segments like[repo:name],[variant.id], and[user@domain]as literal URL segments.Changes
Regex fixes (4 files)
routing/app-route-graph.ts/^\[\.\.\.([\w-]+)\]$//^\[\.\.\.([^\]]+)\]$/routing/pages-router.tsrouting/route-validation.ts/:([\w-]+)\+/g/:([^/]+)\+/gshims/router.ts\[{1,2}(?:\.\.\.)?([\w-]+)\]{1,2}\[{1,2}(?:\.\.\.)?([^\]]+)\]{1,2}Next.js reference
PARAMETER_PATTERN: packages/next/src/shared/lib/router/utils/get-dynamic-param.ts#L175 The[^\]]+group matches any character except\], which is why[repo:name]is valid in Next.js.Test coverage
Added a test in
tests/app-route-graph.test.tsthat verifies routes with dotted, colon, and at-sign param names are materialized correctly.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.