-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
fix: explode optional segments for relative paths in nested routes #9684
Conversation
|
9d5a7d9
to
ae6a2db
Compare
explicitly 'explode' path with optional path segments.
ae6a2db
to
8688e60
Compare
}); | ||
for (let exploded of explodeOptionalSegments(route.path)) { | ||
flattenRoute(route, index, exploded); | ||
} |
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.
I think this is close - but I'm still seeing some ?
's in flattened paths (and also in the then-generated routesMeta.relativePath
. I think always as part of the last optional segment? Here's the flattened/ranked paths for the unit test above:
Otherwise the routesMeta
relative paths are looking right to me though!
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.
I'll try to hit this with a few more complex unit tests scenarios tomorrow as well 👍
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.
Yes, forgot to update code to handle empty segments for nested routes. Should work now!
88b04a3
to
28836f2
Compare
d76bc59
to
e4cc374
Compare
#9650 added support for matching routes with optional path segments, but did not work for nested routes.
This PR fixes that.
It also refactors the approach to explicitly "explode" a path with optional path segments into the equivalent set of valid combinations of paths without optional segments (see
explodeOptionalSegments
jsdoc for an example). The paths are "exploded" prior to creating the route metadata, which means that when the route metadata gets initialized its already correct. Previously, we needed to surgically modify route metadata for a branch (which we were only handling correctly for unnested routes).