Skip to content

Commit

Permalink
less intrusive fix for pathBuilder double slash
Browse files Browse the repository at this point in the history
  • Loading branch information
mjq committed Dec 20, 2024
1 parent 8d14c3f commit 055b614
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/react/src/reactrouterv6-compat-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ function getNormalizedName(

// If path is not a wildcard and has no child routes, append the path
if (path && !pathIsWildcardAndHasChildren(path, branch)) {
const newPath = prefixWithSlash(path);
pathBuilder = trimSlash(pathBuilder) + newPath;
const newPath = path[0] === '/' || pathBuilder[pathBuilder.length - 1] === '/' ? path : `/${path}`;
pathBuilder = trimSlash(pathBuilder) + prefixWithSlash(newPath);

// If the path matches the current location, return the path
if (trimSlash(location.pathname) === trimSlash(basename + branch.pathname)) {
Expand Down

0 comments on commit 055b614

Please sign in to comment.