Unverified Commit 3cf4b17b authored by Wyatt Johnson's avatar Wyatt Johnson Committed by GitHub

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 #85251
parent a135a7d5
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment