mirror of
https://github.com/cloudflare/vinext.git
synced 2026-09-14 19:04:59 +08:00
5d595e08cb
The previous depth-based approach sliced the pathname by a numeric URL depth, which broke when route groups were present — they don't appear in URLs but Next.js includes them in the segments array. This also meant dynamic params were returned as raw URL strings rather than resolved values matching the route tree. Replace `layoutSegmentDepths: number[]` with two new fields: - `routeSegments: string[]` — filesystem segments from app/ root - `layoutTreePositions: number[]` — directory depth per layout Each layout now receives pre-computed child segments through React context (including route groups, with dynamic params resolved to actual values and catch-all segments joined with "/"). Additional fixes found during code review: - Pass matched params to error/fallback rendering paths so dynamic segments resolve correctly during error page rendering - Skip optional catch-all segments when param is empty/undefined - Extend routeSegments for parallel slot sub-routes - Update stale type declaration in next-shims.d.ts Ported from Next.js: test/e2e/app-dir/hooks/hooks.test.ts https://github.com/vercel/next.js/blob/canary/test/e2e/app-dir/hooks/hooks.test.ts