next.js
6cecc754 - Fix dynamic catchall parameter interpolation in parallel routes (#84279)

Commit
110 days ago
Fix dynamic catchall parameter interpolation in parallel routes (#84279) ### Fixing a bug - Tests added with comprehensive e2e test suite for parallel route navigations - Error handling improved with clearer error messages for missing dynamic parameters ### What? Fixes incorrect parameter interpolation where catchall parameters in parallel routes included unintended prefix segments. ### Why? In parallel routes with dynamic catchall parameters, the parameter interpolation was incorrectly including prefix segments from the route path. For example, with a route structure like `/[teamSlug]/@slot/[...catchAll]`, a request to `/vercel/test/path` would incorrectly set `catchAll = ["vercel", "test", "path"]` instead of the correct `catchAll = ["test", "path"]`. This bug affected the accuracy of dynamic parameter values in parallel routes, leading to incorrect behavior in applications relying on these parameters for routing logic. ### How? - Introduced `interpolateParallelRouteParams()` function that properly handles path depth traversal for complex route structures - Refactored parameter interpolation to occur earlier in the render process, ensuring consistency across both postponed and regular rendering scenarios - Updated the `getDynamicParam()` function to use pre-interpolated parameters instead of performing inline path parsing - Added comprehensive e2e tests to cover various parallel route navigation scenarios and parameter interpolation edge cases - Improved error handling with more descriptive error messages for missing dynamic parameters The fix ensures that dynamic parameters are correctly extracted based on their position in the route hierarchy, respecting the boundaries defined by parallel route slots. NAR-335
Author
Parents
Loading