mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #697] [MERGED] fix: use segment-wise pathname decoding in App->Pages Router fallback #779
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#779
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/697
Author: @southpolesteve
Created: 3/27/2026
Status: ✅ Merged
Merged: 3/27/2026
Merged by: @southpolesteve
Base:
main← Head:fix/segment-wise-decode-pages-fallback📝 Commits (1)
1295500fix: use segment-wise pathname decoding in App->Pages fallback📊 Changes
4 files changed (+138 additions, -1 deletions)
View changed files
📝
packages/vinext/src/entries/app-rsc-entry.ts(+10 -1)📝
packages/vinext/src/server/normalize-path.ts(+39 -0)📝
tests/__snapshots__/entry-templates.test.ts.snap(+6 -0)📝
tests/shims.test.ts(+83 -0)📄 Description
Summary
The App Router to Pages Router fallback now uses segment-wise pathname decoding instead of
decodeURIComponent, preserving encoded path delimiters like%2F.Problem
The fallback path used
decodeURIComponent(url.pathname), which decoded%2Fto/, changing the path structure. A request to/security/admin%2Fpanelwould skip a middleware matcher for/security/admin/:path*(since%2Fis not a segment delimiter in the encoded form), but the Pages fallback would decode it to/security/admin/paneland serve the protected page.Fix
Replace
decodeURIComponentwithdecodePathParams(), which:/decodeURIComponent/,#,?) viaescapePathDelimiters/This decodes non-ASCII characters within segments (e.g.,
%C3%A9->e) but preserves the path structure (%2Fstays as%2F).Both utilities are ported from Next.js:
escapePathDelimitersdecodePathParamsTests
escapePathDelimiters: 4 tests (slash, hash, question mark, encoded forms, non-delimiters)decodePathParams: 8 tests (non-ASCII decode, %2F preservation, %23/%3F preservation, mixed paths, malformed encoding, root path)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.