@remix-run/router 1.23.2 → 1.23.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/router.cjs.js +80 -29
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +15 -29
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +80 -29
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/dist/utils.d.ts +1 -0
- package/package.json +1 -1
- package/router.ts +2 -1
- package/utils.ts +9 -18
package/dist/utils.d.ts
CHANGED
|
@@ -439,6 +439,7 @@ export declare function resolveTo(toArg: To, routePathnames: string[], locationP
|
|
|
439
439
|
* @private
|
|
440
440
|
*/
|
|
441
441
|
export declare function getToPathname(to: To): string | undefined;
|
|
442
|
+
export declare const removeDoubleSlashes: (path: string) => string;
|
|
442
443
|
/**
|
|
443
444
|
* @private
|
|
444
445
|
*/
|
package/package.json
CHANGED
package/router.ts
CHANGED
|
@@ -50,6 +50,7 @@ import {
|
|
|
50
50
|
joinPaths,
|
|
51
51
|
matchRoutes,
|
|
52
52
|
matchRoutesImpl,
|
|
53
|
+
removeDoubleSlashes,
|
|
53
54
|
resolveTo,
|
|
54
55
|
stripBasename,
|
|
55
56
|
} from "./utils";
|
|
@@ -5186,7 +5187,7 @@ function normalizeRedirectLocation(
|
|
|
5186
5187
|
}
|
|
5187
5188
|
let isSameBasename = stripBasename(url.pathname, basename) != null;
|
|
5188
5189
|
if (url.origin === currentUrl.origin && isSameBasename) {
|
|
5189
|
-
return url.pathname + url.search + url.hash;
|
|
5190
|
+
return removeDoubleSlashes(url.pathname) + url.search + url.hash;
|
|
5190
5191
|
}
|
|
5191
5192
|
}
|
|
5192
5193
|
|
package/utils.ts
CHANGED
|
@@ -545,6 +545,7 @@ export function matchRoutesImpl<
|
|
|
545
545
|
rankRouteBranches(branches);
|
|
546
546
|
|
|
547
547
|
let matches = null;
|
|
548
|
+
let decoded = decodePath(pathname);
|
|
548
549
|
for (let i = 0; matches == null && i < branches.length; ++i) {
|
|
549
550
|
// Incoming pathnames are generally encoded from either window.location
|
|
550
551
|
// or from router.navigate, but we want to match against the unencoded
|
|
@@ -552,7 +553,6 @@ export function matchRoutesImpl<
|
|
|
552
553
|
// encoded here but there also shouldn't be anything to decode so this
|
|
553
554
|
// should be a safe operation. This avoids needing matchRoutes to be
|
|
554
555
|
// history-aware.
|
|
555
|
-
let decoded = decodePath(pathname);
|
|
556
556
|
matches = matchRouteBranch<string, RouteObjectType>(
|
|
557
557
|
branches[i],
|
|
558
558
|
decoded,
|
|
@@ -1145,23 +1145,11 @@ export function resolvePath(to: To, fromPathname = "/"): Path {
|
|
|
1145
1145
|
|
|
1146
1146
|
let pathname: string;
|
|
1147
1147
|
if (toPathname) {
|
|
1148
|
-
|
|
1149
|
-
|
|
1148
|
+
toPathname = removeDoubleSlashes(toPathname);
|
|
1149
|
+
if (toPathname.startsWith("/")) {
|
|
1150
|
+
pathname = resolvePathname(toPathname.substring(1), "/");
|
|
1150
1151
|
} else {
|
|
1151
|
-
|
|
1152
|
-
let oldPathname = toPathname;
|
|
1153
|
-
toPathname = toPathname.replace(/\/\/+/g, "/");
|
|
1154
|
-
warning(
|
|
1155
|
-
false,
|
|
1156
|
-
`Pathnames cannot have embedded double slashes - normalizing ` +
|
|
1157
|
-
`${oldPathname} -> ${toPathname}`
|
|
1158
|
-
);
|
|
1159
|
-
}
|
|
1160
|
-
if (toPathname.startsWith("/")) {
|
|
1161
|
-
pathname = resolvePathname(toPathname.substring(1), "/");
|
|
1162
|
-
} else {
|
|
1163
|
-
pathname = resolvePathname(toPathname, fromPathname);
|
|
1164
|
-
}
|
|
1152
|
+
pathname = resolvePathname(toPathname, fromPathname);
|
|
1165
1153
|
}
|
|
1166
1154
|
} else {
|
|
1167
1155
|
pathname = fromPathname;
|
|
@@ -1353,11 +1341,14 @@ export function getToPathname(to: To): string | undefined {
|
|
|
1353
1341
|
: to.pathname;
|
|
1354
1342
|
}
|
|
1355
1343
|
|
|
1344
|
+
export const removeDoubleSlashes = (path: string): string =>
|
|
1345
|
+
path.replace(/\/\/+/g, "/");
|
|
1346
|
+
|
|
1356
1347
|
/**
|
|
1357
1348
|
* @private
|
|
1358
1349
|
*/
|
|
1359
1350
|
export const joinPaths = (paths: string[]): string =>
|
|
1360
|
-
paths.join("/")
|
|
1351
|
+
removeDoubleSlashes(paths.join("/"));
|
|
1361
1352
|
|
|
1362
1353
|
/**
|
|
1363
1354
|
* @private
|