@remix-run/router 1.15.0 → 1.15.1
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 +6 -0
- package/dist/router.cjs.js +10 -14
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +10 -14
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +10 -14
- 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/history.ts +4 -0
- package/package.json +1 -1
- package/utils.ts +14 -28
package/dist/router.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.15.
|
|
2
|
+
* @remix-run/router v1.15.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -498,6 +498,10 @@
|
|
|
498
498
|
// See https://bugzilla.mozilla.org/show_bug.cgi?id=878297
|
|
499
499
|
let base = window.location.origin !== "null" ? window.location.origin : window.location.href;
|
|
500
500
|
let href = typeof to === "string" ? to : createPath(to);
|
|
501
|
+
// Treating this as a full URL will strip any trailing spaces so we need to
|
|
502
|
+
// pre-encode them since they might be part of a matching splat param from
|
|
503
|
+
// an ancestor route
|
|
504
|
+
href = href.replace(/ $/, "%20");
|
|
501
505
|
invariant(base, "No window.location.(origin|href) available to create URL for href: " + href);
|
|
502
506
|
return new URL(href, base);
|
|
503
507
|
}
|
|
@@ -754,14 +758,14 @@
|
|
|
754
758
|
rankRouteBranches(branches);
|
|
755
759
|
let matches = null;
|
|
756
760
|
for (let i = 0; matches == null && i < branches.length; ++i) {
|
|
757
|
-
matches = matchRouteBranch(branches[i],
|
|
758
761
|
// Incoming pathnames are generally encoded from either window.location
|
|
759
762
|
// or from router.navigate, but we want to match against the unencoded
|
|
760
763
|
// paths in the route definitions. Memory router locations won't be
|
|
761
764
|
// encoded here but there also shouldn't be anything to decode so this
|
|
762
765
|
// should be a safe operation. This avoids needing matchRoutes to be
|
|
763
766
|
// history-aware.
|
|
764
|
-
|
|
767
|
+
let decoded = decodePath(pathname);
|
|
768
|
+
matches = matchRouteBranch(branches[i], decoded);
|
|
765
769
|
}
|
|
766
770
|
return matches;
|
|
767
771
|
}
|
|
@@ -1040,7 +1044,7 @@
|
|
|
1040
1044
|
if (isOptional && !value) {
|
|
1041
1045
|
memo[paramName] = undefined;
|
|
1042
1046
|
} else {
|
|
1043
|
-
memo[paramName] =
|
|
1047
|
+
memo[paramName] = (value || "").replace(/%2F/g, "/");
|
|
1044
1048
|
}
|
|
1045
1049
|
return memo;
|
|
1046
1050
|
}, {});
|
|
@@ -1092,22 +1096,14 @@
|
|
|
1092
1096
|
let matcher = new RegExp(regexpSource, caseSensitive ? undefined : "i");
|
|
1093
1097
|
return [matcher, params];
|
|
1094
1098
|
}
|
|
1095
|
-
function
|
|
1099
|
+
function decodePath(value) {
|
|
1096
1100
|
try {
|
|
1097
|
-
return
|
|
1101
|
+
return value.split("/").map(v => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
|
|
1098
1102
|
} catch (error) {
|
|
1099
1103
|
warning(false, "The URL path \"" + value + "\" could not be decoded because it is is a " + "malformed URL segment. This is probably due to a bad percent " + ("encoding (" + error + ")."));
|
|
1100
1104
|
return value;
|
|
1101
1105
|
}
|
|
1102
1106
|
}
|
|
1103
|
-
function safelyDecodeURIComponent(value, paramName) {
|
|
1104
|
-
try {
|
|
1105
|
-
return decodeURIComponent(value);
|
|
1106
|
-
} catch (error) {
|
|
1107
|
-
warning(false, "The value for the URL param \"" + paramName + "\" will not be decoded because" + (" the string \"" + value + "\" is a malformed URL segment. This is probably") + (" due to a bad percent encoding (" + error + ")."));
|
|
1108
|
-
return value;
|
|
1109
|
-
}
|
|
1110
|
-
}
|
|
1111
1107
|
|
|
1112
1108
|
/**
|
|
1113
1109
|
* @private
|