mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 00:09:23 +02:00
[PR #783] [MERGED] fix: extract actual URL params for intercepting route source routes #841
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#841
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/783
Author: @NathanDrake2406
Created: 4/4/2026
Status: ✅ Merged
Merged: 4/5/2026
Merged by: @james-elicx
Base:
main← Head:fix/intercept-route-source-params📝 Commits (4)
534d977fix: deduplicate inherited intercept target patterns in validation34362a6fix: extract actual URL params for intercepting route source routesb9c0ab4fix: handle optional catch-all in source route param extraction13d02ectest: update entry template snapshots for catch-all reorder📊 Changes
9 files changed (+279 additions, -12 deletions)
View changed files
📝
packages/vinext/src/entries/app-rsc-entry.ts(+25 -1)📝
packages/vinext/src/routing/app-router.ts(+11 -5)📝
tests/__snapshots__/entry-templates.test.ts.snap(+150 -6)📝
tests/app-router.test.ts(+48 -0)➕
tests/fixtures/app-basic/app/team/[teamId]/members/@modal/(..)settings/page.tsx(+11 -0)➕
tests/fixtures/app-basic/app/team/[teamId]/members/@modal/default.tsx(+3 -0)➕
tests/fixtures/app-basic/app/team/[teamId]/members/layout.tsx(+14 -0)➕
tests/fixtures/app-basic/app/team/[teamId]/members/page.tsx(+8 -0)➕
tests/fixtures/app-basic/app/team/[teamId]/settings/page.tsx(+9 -0)📄 Description
Summary
matchSourceRouteParamsin the generated RSC entry to extract actual URL param values instead of literal pattern strings (e.g.{teamId: "42"}instead of{teamId: ":teamId"}).The bug
When an intercepting route's source route has dynamic segments (e.g.
/team/[teamId]/memberswith@modal/(..)settings), the generatedmatchSourceRouteParamscallback calledmatchRoute(pattern)— feeding the source route's pattern string through the URL trie. The trie's dynamic child matched the literal:teamIdas a segment value, producing{teamId: ":teamId"}instead of extracting the real value from the request URL.This only triggers on cross-route interception (source route != current route) with dynamic source routes. The existing tests used a static source route (
/feed) so the bug was not caught.The fix
Replace
matchRoute(pattern)with a prefix-match param extractor that walks the source pattern and request URL (cleanPathname) in parallel::param) extract the corresponding URL segment value+/*) consume remaining URL partsThis correctly handles all interception conventions:
(.)same-level,(..)one-level-up, and(...)root.Additionally, the intercept target pattern validation now deduplicates patterns via
Setbefore checking for duplicates, since child routes inherit parent slots (and their intercepts), causing false duplicate detection.Test plan
/team/42/settingswith dynamic source route/team/:teamId/membersverifies params contain"42"not":teamId"/team/42/membersand/team/42/settingsrender correctly/feedwith(...)photos/[id])routing.test.ts,route-sorting.test.ts)app-page-request.test.tsunit tests pass🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.