mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #78] [MERGED] fix(routing): allow hyphens in dynamic segment param names #293
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#293
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/78
Author: @ask-bonk[bot]
Created: 2/25/2026
Status: ✅ Merged
Merged: 2/27/2026
Merged by: @FredKSchott
Base:
main← Head:opencode/issue71-20260225213338📝 Commits (2)
ddcd8e9fix(routing): allow hyphens in dynamic segment param names3d567a0fix(routing): allow hyphens in config matching and middleware-codegen param patterns📊 Changes
14 files changed (+260 additions, -39 deletions)
View changed files
📝
packages/vinext/src/config/config-matchers.ts(+9 -6)📝
packages/vinext/src/index.ts(+5 -3)📝
packages/vinext/src/routing/app-router.ts(+12 -12)📝
packages/vinext/src/routing/pages-router.ts(+9 -9)📝
packages/vinext/src/server/app-dev-server.ts(+7 -7)📝
packages/vinext/src/server/middleware-codegen.ts(+1 -1)📝
packages/vinext/src/server/middleware.ts(+2 -1)📝
tests/app-router.test.ts(+33 -0)➕
tests/fixtures/app-basic/app/auth/[auth-method]/page.tsx(+13 -0)➕
tests/fixtures/app-basic/app/sign-in/[[...sign-in]]/page.tsx(+15 -0)➕
tests/fixtures/pages-basic/pages/sign-up/[[...sign-up]]/index.tsx(+21 -0)📝
tests/pages-router.test.ts(+22 -0)📝
tests/route-sorting.test.ts(+12 -0)📝
tests/routing.test.ts(+99 -0)📄 Description
Summary
Fixes #71 — catch-all route params with hyphens (e.g.
[[...sign-in]]) caused 404 because the regex used\w+which doesn't match-. Next.js allows hyphens in param directory names, and this is the standard pattern scaffolded by Clerk ([[...sign-in]],[[...sign-up]]).Changes
\w+regex patterns to[\w-]+across 4 source files (15 regex instances total):app-router.ts—fileToAppRoute(),discoverSlotSubRoutes(),computeInterceptTarget()pages-router.ts—fileToRoute(),patternToNextFormat()app-dev-server.ts— middleware matcher regex, config pattern matching guardmiddleware.ts—matchMiddlewarePath()pattern conversion[[...sign-in]]and[auth-method](App Router),[[...sign-up]](Pages Router)routing.test.ts— 10 unit tests for route discovery and URL matching with hyphenated paramsroute-sorting.test.ts— 3 tests forpatternToNextFormat()with hyphenated paramsapp-router.test.ts— 3 integration tests (dev server renders hyphenated routes)pages-router.test.ts— 2 integration tests (dev server renders hyphenated routes)Dev/prod parity
The fix applies to both dev and production code paths. The
matchPattern()functions in both routers use string slicing (not regex) to extract param names from the internal:paramformat, so they already handle hyphens correctly — no changes needed there.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.