mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #127] [CLOSED] fix(middleware-codegen): allow hyphens in path param names in generated matcher #334
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#334
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/127
Author: @SeolJaeHyeok
Created: 2/26/2026
Status: ❌ Closed
Base:
main← Head:fix/middleware-codegen-hyphen-params📝 Commits (1)
a3d9a9ffix(middleware-codegen): allow hyphens in path param names in generated matcher📊 Changes
1 file changed (+1 additions, -1 deletions)
View changed files
📝
packages/vinext/src/server/middleware-codegen.ts(+1 -1)📄 Description
Summary
middleware-codegen.tsgenerates thematchMiddlewarePattern()function thatis inlined into the production RSC entry (
worker/index.ts). ThetokenReregex used
[\w]+for path parameter capture groups, which does not matchhyphens — so middleware matchers with hyphenated param names silently failed
in production.
Problem
A middleware config.matcher like "/:sign-in*" or "/auth/:reset-password"
would not be recognised as a param pattern and treated as a literal string,
causing the matcher to never fire in production.
This is a production-only gap. The dev path executes matchPattern() from
middleware.ts directly; the production RSC entry uses the generated string
from middleware-codegen.ts — and only the generated version had the bug.
Relation to PR #78
PR #78 fixes the same \w+ issue in middleware.ts (the dev path) and several
routing files, but middleware-codegen.ts was added to main after PR #78
was opened, so it was not included in that scope.
The file's own comment states:
The pattern matching logic must be identical to matchPattern() in
middleware.ts. Any changes here must be mirrored there and vice versa.
This PR applies that mirroring proactively, so dev and prod stay consistent
when PR #78 lands.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.