Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
fix(react): improve handling of routes nested under path="/"#14821
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -427,10 +427,10 @@ function getNormalizedName( | ||
| // If path is not a wildcard and has no child routes, append the path | ||
| if (path && !pathIsWildcardAndHasChildren(path, branch)) { | ||
| const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`; | ||
| pathBuilder += newPath; | ||
| pathBuilder = trimSlash(pathBuilder) + prefixWithSlash(newPath); | ||
| // If the path matches the current location, return the path | ||
| if (location.pathname.endsWith(basename + branch.pathname)) { | ||
| if (trimSlash(location.pathname) === trimSlash(basename + branch.pathname)) { | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd expect this to break descendant routes. But in the final implementation, descendant routes don't end up here. So, I believe it's safe to revert. | ||
| if ( | ||
| // If the route defined on the element is something like | ||
| // <Route path="/stores/:storeId/products/:productId" element={<div>Product</div>} /> | ||
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.
Originally I thought to change these lines to
but
newPathis used in a different path concatenation further down the method and, even though no tests fail, I didn't want collateral damage. (Tests probably should have failed though - I think the path concatenation in this method could be better handled, and is under-tested.)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 we can make a refactor/cleanup once we get the tests in a better state.