mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #456] [MERGED] fix: Preserve encoded path delimiters in route discovery and matching #584
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#584
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/456
Author: @JaredStowell
Created: 3/11/2026
Status: ✅ Merged
Merged: 3/11/2026
Merged by: @james-elicx
Base:
main← Head:jstowell/fix-encoded-slash-route-segments📝 Commits (6)
06802afFix App Router decoding collision847405fFix App Router path decoding6150327Merge remote-tracking branch 'origin/main' into jstowell/fix-encoded-slash-route-segments8f7874eAddress bonk review: codegen safe segment decode, static serving, nitseb0ab60fix: add codegen strict normalizer, use it at 400-returning call sitesc7c847fMerge remote-tracking branch 'origin/main' into jstowell/fix-encoded-slash-route-segments📊 Changes
13 files changed (+483 additions, -52 deletions)
View changed files
📝
packages/vinext/src/entries/app-rsc-entry.ts(+6 -4)📝
packages/vinext/src/entries/pages-server-entry.ts(+3 -1)📝
packages/vinext/src/index.ts(+2 -1)📝
packages/vinext/src/routing/app-router.ts(+3 -11)📝
packages/vinext/src/routing/pages-router.ts(+3 -7)📝
packages/vinext/src/routing/utils.ts(+52 -0)📝
packages/vinext/src/server/middleware-codegen.ts(+40 -0)📝
packages/vinext/src/server/middleware.ts(+2 -1)📝
packages/vinext/src/server/prod-server.ts(+3 -2)📝
tests/__snapshots__/entry-templates.test.ts.snap(+207 -25)📝
tests/app-router.test.ts(+20 -0)📝
tests/pages-router.test.ts(+99 -0)📝
tests/routing.test.ts(+43 -0)📄 Description
Preserve encoded path delimiters throughout route discovery, route matching, and live request handling.
Previously, vinext decoded entire pathnames with
decodeURIComponentin several routing paths. That caused encoded delimiters like%2Fto collapse into real path separators, so routes such asapp/a%2Fb/page.tsxandapp/a/b/page.tsxcould collide during discovery or be misrouted at runtime.This change switches vinext to segment-wise pathname normalization that preserves encoded path delimiters while still decoding safe escapes.
What changed
Behavior
%5Fstill decodes to_%2F,%23,%3F, and%5Cremain encoded within a segment400instead of crashingWhy
This fixes real route collisions and dev/prod mismatches around encoded slashes, and keeps request-time routing in parity with the new discovery logic instead of only fixing the shared helpers.
Testing
pnpm test tests/routing.test.ts tests/app-router.test.ts tests/pages-router.test.ts tests/entry-templates.test.tspnpm run fmtpnpm run typecheckpnpm test🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.