mirror of
https://github.com/cloudflare/vinext.git
synced 2026-05-09 08:25:34 +02:00
[PR #1040] [MERGED] fix(routing): match inherited slot params against routePath, not request.url #1041
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#1041
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/1040
Author: @james-elicx
Created: 5/3/2026
Status: ✅ Merged
Merged: 5/3/2026
Merged by: @james-elicx
Base:
main← Head:fix/inherited-slot-basepath-and-memoize📝 Commits (1)
f35c27bfix(routing): match inherited slot params against routePath, not request.url📊 Changes
3 files changed (+99 additions, -15 deletions)
View changed files
📝
packages/vinext/src/routing/app-route-graph.ts(+29 -9)📝
packages/vinext/src/server/app-page-element-builder.ts(+10 -6)📝
tests/app-page-element-builder.test.ts(+60 -0)📄 Description
Follow-up to #1039, addressing two items I missed during review.
Summary
basePath:buildSlotOverrideswas deriving the URL parts to match againstslot.slotPatternPartsfromrequest.url. The original request URL still carries the configuredbasePath, butslotPatternPartsis built from app-relative segments only — so for any basePath-configured app, the pattern match silently failed and slot params fell back to the route's matched params (the exact bug #1039 was supposed to fix). Switched to the already-normalizedroutePathparameter (basePath stripped, RSC suffix removed) thatbuildPageElementsalready receives.findSlotSubPages: cached per-build via aWeakMapkeyed by the matcher. Inherited slots get scanned once per descendant route, so without memoization a route N segments deep paid O(N) full subtree walks for every shared ancestor slot. Cache lifetime tracks the matcher (one per build), so a long-lived dev server doesn't accumulate state across builds.findMirroredSlotPagewas callingconvertSegmentsToRouteParts(segmentsBelow)twice when the literal-tier match missed. Hoisted it out so both tiers reuse the conversion.Test plan
tests/app-page-element-builder.test.tsexercises the basePath regression: request URL ishttp://localhost/base/distinct/alicewhileroutePathis/distinct/alice, slot hasslotPatternParts: ["distinct", ":name"]. Without the fix,urlPartswould be["base","distinct","alice"], the match would fail, and the slot's resolvedparamswould silently lose thenamevalue. With the fix,slotParamsresolves to{ name: "alice" }.pnpm exec vp test run --project unit— 3524 tests pass.pnpm check— only pre-existing failure (benchmarks/vinext/vite.config.tscannot resolvevinextuntil the package is built; same onmain).🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.