mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #495] [MERGED] fix: parse :param(constraint) in middleware matchers #616
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#616
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/495
Author: @NathanDrake2406
Created: 3/12/2026
Status: ✅ Merged
Merged: 3/12/2026
Merged by: @james-elicx
Base:
main← Head:fix/middleware-param-constraints📝 Commits (2)
09079c2fix: parse :param(constraint) in middleware matchers75f22e3fix: support constraints on catch-all params and add negative optional test📊 Changes
4 files changed (+206 additions, -18 deletions)
View changed files
📝
packages/vinext/src/server/middleware-codegen.ts(+37 -4)📝
packages/vinext/src/server/middleware.ts(+47 -6)📝
tests/__snapshots__/entry-templates.test.ts.snap(+74 -8)📝
tests/shims.test.ts(+48 -0)📄 Description
Summary
compileMatcherPattern) treated any pattern containing(as a raw regex, so/blog/:id(\d+)was compiled as the literal regex^/blog/:id(\d+)$— matching/blog/:id123instead of/blog/123extractConstraint()approach fromconfig-matchers.ts: when(follows a:paramname, extract it as an inline regex constraint and emit a proper capture group:param(syntax (e.g./((?!api|_next).*)) still take the raw regex path:param(constraint)?for optional constrained segments (e.g./:locale(en|es|fr)?/aboutmatches both/aboutand/en/about)middleware-codegen.tsto keep runtime and generated code in syncTest plan
matchPatterntests for:id(\d+)constraint (positive and negative)matchPatterntests for:locale(en|es|fr)alternation constraintmatchPatterntests for:locale(en|es|fr)?optional constraintmodernandes5codegen paths🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.