Commit 3cf4b17
authored
fix(static-paths): add depth tracking to parallel route param resolution (#85319)
### What?
Adds depth-aware parameter resolution to `resolveParallelRouteParams` by
migrating from simplified parallel route segments to LoaderTree
structure.
### Why?
Dynamic and intercepted parameters in parallel routes were not being
correctly extracted when used at nested depths. The previous
implementation didn't account for:
- Route nesting level when matching pathname segments to parameters
- Route groups (which don't affect depth) vs interception routes (which
do)
- Embedded parameters that need resolution before depth calculation
This caused incorrect behavior in real-world scenarios like:
- Nested parallel routes at different depths
- Interception routes with parallel routes
- ISR/generateStaticParams with complex routing structures
### How?
1. **LoaderTree Integration**: Migrated from `ParallelRouteSegment[]` to
LoaderTree structure for accurate routing hierarchy representation
2. **Depth Tracking**: Recursively traverse LoaderTree to calculate
depth, accounting for:
- Static segments (increment depth)
- Dynamic segments (increment depth)
- Route groups `()` - don't increment depth
- Interception routes `(.)` `(..)` `(...)` - do increment depth
3. **Smart Parameter Extraction**:
- Check if pathname segment at calculated depth is a placeholder
- Only extract if segment is known (not `[paramName]`)
- Resolve embedded params before extraction
4. **Comprehensive Tests**: Added test coverage for:
- Dynamic params at various depths
- Route groups vs interception routes
- Catchall/optional-catchall with depth
- Complex nested scenarios
Fixes #852511 parent a135a7d commit 3cf4b17
2 files changed
+1250
-165
lines changed
0 commit comments