Skip to content

fix: App Router route-group and slot collision#447

Open
JaredStowell wants to merge 2 commits intocloudflare:mainfrom
JaredStowell:jstowell/fix-app-route-group-collisions
Open

fix: App Router route-group and slot collision#447
JaredStowell wants to merge 2 commits intocloudflare:mainfrom
JaredStowell:jstowell/fix-app-route-group-collisions

Conversation

@JaredStowell
Copy link
Contributor

Fix App Router collision handling when multiple filesystem entries resolve to the same visible URL.

This changes route discovery and validation to:

  • reject duplicate normalized route patterns after route-group elision
  • treat /foo and /foo/ as the same route during validation
  • reject grouped slot sub-pages that collapse to the same URL within the same slot
  • reject slot sub-pages that collide with route.ts handlers
  • preserve shadowing semantics for same-named slots at different layout depths
  • merge matching slot sub-pages from different slots onto the same synthesized route

Details

In app-router.ts:

  • track slot ownership with internal ownerDir metadata
  • key synthetic slot merges by (slot name, owner dir) instead of slot name alone
  • normalize visible slot subpaths before duplicate detection
  • throw on page-vs-route-handler collisions
  • stop generating slash-suffixed synthetic patterns for empty/group-only subpaths

In route-validation.ts:

  • canonicalize trailing slashes before duplicate checks and dynamic-route validation

Tests

Added regressions for:

  • duplicate normalized patterns
  • slash-equivalent patterns
  • route-group duplicates like (a)/about vs (b)/about
  • grouped slot sub-page duplicates within one slot
  • grouped slot sub-pages from different slots merging correctly
  • slot sub-pages colliding with route.ts
  • parent slot sub-pages not overwriting a shadowing child slot of the same name

Verification

Passed:

  • pnpm test tests/route-sorting.test.ts
  • pnpm test tests/routing.test.ts
  • pnpm test tests/app-router.test.ts
  • pnpm run fmt
  • pnpm run typecheck

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 11, 2026

Open in StackBlitz

npm i https://pkg.pr.new/vinext@447

commit: 0ee2420

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant