-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix(router-core): buildLocation should interpolatePath w/ stringified params for skipRouteOnParseError routes #6491
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… params for skipRouteOnParseError routes
📝 WalkthroughWalkthroughExports Changes
Sequence Diagram(s)sequenceDiagram
participant Router as Router.buildLocation
participant Branch as buildRouteBranch
participant Route as Route.stringify
participant Interp as interpolatePath
participant Dest as DestinationResolver
Router->>Branch: request branch for target route
Branch-->>Router: route branch (stringifiers)
Router->>Route: apply stringify across branch -> prestringifiedParams
Route-->>Router: prestringifiedParams
Router->>Interp: interpolatePath(nextTo, prestringifiedParams, decoder)
Interp-->>Router: interpolatedNextTo
Router->>Dest: resolve destination with interpolatedNextTo
Dest-->>Router: resolved destination (fullPath)
alt destination matches trimmed target
Router->>Router: use interpolatedNextTo as nextPathname
else destination mismatch
Router->>Route: compute stringifiedParams fallback
Route-->>Router: stringifiedParams
Router->>Interp: interpolatePath(nextTo, stringifiedParams)
Interp-->>Router: nextPathname
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Comment |
|
View your CI Pipeline Execution ↗ for commit 6f09b9f
☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/router-core/src/router.ts`:
- Around line 1803-1807: The interpolatedNextTo is currently built from
nextParams (parsed values) but later code sometimes needs the stringified values
in prestringifiedParams; change the interpolation so that when
prestringifiedParams is provided you call interpolatePath with params:
prestringifiedParams (and same decoder) instead of nextParams, or alternatively
compute a second value (e.g., interpolatedPrestringifiedNextTo) by calling
interpolatePath({ path: nextTo, params: prestringifiedParams, decoder:
this.pathParamsDecoder }) and use that result wherever the code currently
branches on prestringifiedParams (including the return path and any route
matching that relies on interpolatedNextTo). Ensure the unique symbols involved
are interpolatePath, interpolatedNextTo (or new
interpolatedPrestringifiedNextTo), nextParams, and prestringifiedParams so the
correct interpolated pathname is returned and used for matching.
Fixes #6490
Warning
I'm not 100% convinced this is a good idea.
Possible issues:
toprops, and then it wouldn't match anything in theroutesByPathlookupto(intended behavior) but by then we will have stringified the params using the originalto(weird behavior?)encodeURIComponentthe params instead of going throughparams.stringify? I have a hard time believing we always know which route branch we're working onHowever, if you respect the types, and you don't have a crazy route setup that makes conflict likely, then this is pretty powerful (see original issue).
The alternatives are:
skipRouteOnParseError.params: trueandparams.stringifyskipRouteOnParseError.paramsthan the one used for "reversing the stringification"🤷
Summary by CodeRabbit
New Features
Improvements
Tests
✏️ Tip: You can customize this high-level summary in your review settings.