@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/router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.23.
|
|
2
|
+
* @remix-run/router v1.23.4
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -9,18 +9,13 @@
|
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
11
|
function _extends() {
|
|
12
|
-
_extends = Object.assign ? Object.assign.bind() : function (
|
|
13
|
-
for (var
|
|
14
|
-
var
|
|
15
|
-
for (var
|
|
16
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
17
|
-
target[key] = source[key];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
12
|
+
return _extends = Object.assign ? Object.assign.bind() : function (n) {
|
|
13
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
14
|
+
var t = arguments[e];
|
|
15
|
+
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
|
|
20
16
|
}
|
|
21
|
-
return
|
|
22
|
-
};
|
|
23
|
-
return _extends.apply(this, arguments);
|
|
17
|
+
return n;
|
|
18
|
+
}, _extends.apply(null, arguments);
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
////////////////////////////////////////////////////////////////////////////////
|
|
@@ -529,6 +524,7 @@ function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
|
|
|
529
524
|
let branches = flattenRoutes(routes);
|
|
530
525
|
rankRouteBranches(branches);
|
|
531
526
|
let matches = null;
|
|
527
|
+
let decoded = decodePath(pathname);
|
|
532
528
|
for (let i = 0; matches == null && i < branches.length; ++i) {
|
|
533
529
|
// Incoming pathnames are generally encoded from either window.location
|
|
534
530
|
// or from router.navigate, but we want to match against the unencoded
|
|
@@ -536,7 +532,6 @@ function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
|
|
|
536
532
|
// encoded here but there also shouldn't be anything to decode so this
|
|
537
533
|
// should be a safe operation. This avoids needing matchRoutes to be
|
|
538
534
|
// history-aware.
|
|
539
|
-
let decoded = decodePath(pathname);
|
|
540
535
|
matches = matchRouteBranch(branches[i], decoded, allowPartial);
|
|
541
536
|
}
|
|
542
537
|
return matches;
|
|
@@ -886,8 +881,6 @@ function stripBasename(pathname, basename) {
|
|
|
886
881
|
}
|
|
887
882
|
return pathname.slice(startIndex) || "/";
|
|
888
883
|
}
|
|
889
|
-
const ABSOLUTE_URL_REGEX$1 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
890
|
-
const isAbsoluteUrl = url => ABSOLUTE_URL_REGEX$1.test(url);
|
|
891
884
|
/**
|
|
892
885
|
* Returns a resolved path object relative to the given pathname.
|
|
893
886
|
*
|
|
@@ -904,19 +897,11 @@ function resolvePath(to, fromPathname) {
|
|
|
904
897
|
} = typeof to === "string" ? parsePath(to) : to;
|
|
905
898
|
let pathname;
|
|
906
899
|
if (toPathname) {
|
|
907
|
-
|
|
908
|
-
|
|
900
|
+
toPathname = removeDoubleSlashes(toPathname);
|
|
901
|
+
if (toPathname.startsWith("/")) {
|
|
902
|
+
pathname = resolvePathname(toPathname.substring(1), "/");
|
|
909
903
|
} else {
|
|
910
|
-
|
|
911
|
-
let oldPathname = toPathname;
|
|
912
|
-
toPathname = toPathname.replace(/\/\/+/g, "/");
|
|
913
|
-
warning(false, "Pathnames cannot have embedded double slashes - normalizing " + (oldPathname + " -> " + toPathname));
|
|
914
|
-
}
|
|
915
|
-
if (toPathname.startsWith("/")) {
|
|
916
|
-
pathname = resolvePathname(toPathname.substring(1), "/");
|
|
917
|
-
} else {
|
|
918
|
-
pathname = resolvePathname(toPathname, fromPathname);
|
|
919
|
-
}
|
|
904
|
+
pathname = resolvePathname(toPathname, fromPathname);
|
|
920
905
|
}
|
|
921
906
|
} else {
|
|
922
907
|
pathname = fromPathname;
|
|
@@ -1044,10 +1029,11 @@ function getToPathname(to) {
|
|
|
1044
1029
|
// Empty strings should be treated the same as / paths
|
|
1045
1030
|
return to === "" || to.pathname === "" ? "/" : typeof to === "string" ? parsePath(to).pathname : to.pathname;
|
|
1046
1031
|
}
|
|
1032
|
+
const removeDoubleSlashes = path => path.replace(/\/\/+/g, "/");
|
|
1047
1033
|
/**
|
|
1048
1034
|
* @private
|
|
1049
1035
|
*/
|
|
1050
|
-
const joinPaths = paths => paths.join("/")
|
|
1036
|
+
const joinPaths = paths => removeDoubleSlashes(paths.join("/"));
|
|
1051
1037
|
/**
|
|
1052
1038
|
* @private
|
|
1053
1039
|
*/
|
|
@@ -4449,7 +4435,7 @@ function normalizeRedirectLocation(location, currentUrl, basename, historyInstan
|
|
|
4449
4435
|
}
|
|
4450
4436
|
let isSameBasename = stripBasename(url.pathname, basename) != null;
|
|
4451
4437
|
if (url.origin === currentUrl.origin && isSameBasename) {
|
|
4452
|
-
return url.pathname + url.search + url.hash;
|
|
4438
|
+
return removeDoubleSlashes(url.pathname) + url.search + url.hash;
|
|
4453
4439
|
}
|
|
4454
4440
|
}
|
|
4455
4441
|
try {
|