Skip to content

Commit 055b614

Browse files
committed
less intrusive fix for pathBuilder double slash
1 parent 8d14c3f commit 055b614

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/react/src/reactrouterv6-compat-utils.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ function getNormalizedName(
426426

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

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

0 commit comments

Comments
 (0)