@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/history.ts
CHANGED
|
@@ -690,6 +690,10 @@ function getUrlBasedHistory(
|
|
|
690
690
|
: window.location.href;
|
|
691
691
|
|
|
692
692
|
let href = typeof to === "string" ? to : createPath(to);
|
|
693
|
+
// Treating this as a full URL will strip any trailing spaces so we need to
|
|
694
|
+
// pre-encode them since they might be part of a matching splat param from
|
|
695
|
+
// an ancestor route
|
|
696
|
+
href = href.replace(/ $/, "%20");
|
|
693
697
|
invariant(
|
|
694
698
|
base,
|
|
695
699
|
`No window.location.(origin|href) available to create URL for href: ${href}`
|
package/package.json
CHANGED
package/utils.ts
CHANGED
|
@@ -485,16 +485,14 @@ export function matchRoutes<
|
|
|
485
485
|
|
|
486
486
|
let matches = null;
|
|
487
487
|
for (let i = 0; matches == null && i < branches.length; ++i) {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
safelyDecodeURI(pathname)
|
|
497
|
-
);
|
|
488
|
+
// Incoming pathnames are generally encoded from either window.location
|
|
489
|
+
// or from router.navigate, but we want to match against the unencoded
|
|
490
|
+
// paths in the route definitions. Memory router locations won't be
|
|
491
|
+
// encoded here but there also shouldn't be anything to decode so this
|
|
492
|
+
// should be a safe operation. This avoids needing matchRoutes to be
|
|
493
|
+
// history-aware.
|
|
494
|
+
let decoded = decodePath(pathname);
|
|
495
|
+
matches = matchRouteBranch<string, RouteObjectType>(branches[i], decoded);
|
|
498
496
|
}
|
|
499
497
|
|
|
500
498
|
return matches;
|
|
@@ -930,7 +928,7 @@ export function matchPath<
|
|
|
930
928
|
if (isOptional && !value) {
|
|
931
929
|
memo[paramName] = undefined;
|
|
932
930
|
} else {
|
|
933
|
-
memo[paramName] =
|
|
931
|
+
memo[paramName] = (value || "").replace(/%2F/g, "/");
|
|
934
932
|
}
|
|
935
933
|
return memo;
|
|
936
934
|
},
|
|
@@ -1002,9 +1000,12 @@ function compilePath(
|
|
|
1002
1000
|
return [matcher, params];
|
|
1003
1001
|
}
|
|
1004
1002
|
|
|
1005
|
-
function
|
|
1003
|
+
function decodePath(value: string) {
|
|
1006
1004
|
try {
|
|
1007
|
-
return
|
|
1005
|
+
return value
|
|
1006
|
+
.split("/")
|
|
1007
|
+
.map((v) => decodeURIComponent(v).replace(/\//g, "%2F"))
|
|
1008
|
+
.join("/");
|
|
1008
1009
|
} catch (error) {
|
|
1009
1010
|
warning(
|
|
1010
1011
|
false,
|
|
@@ -1017,21 +1018,6 @@ function safelyDecodeURI(value: string) {
|
|
|
1017
1018
|
}
|
|
1018
1019
|
}
|
|
1019
1020
|
|
|
1020
|
-
function safelyDecodeURIComponent(value: string, paramName: string) {
|
|
1021
|
-
try {
|
|
1022
|
-
return decodeURIComponent(value);
|
|
1023
|
-
} catch (error) {
|
|
1024
|
-
warning(
|
|
1025
|
-
false,
|
|
1026
|
-
`The value for the URL param "${paramName}" will not be decoded because` +
|
|
1027
|
-
` the string "${value}" is a malformed URL segment. This is probably` +
|
|
1028
|
-
` due to a bad percent encoding (${error}).`
|
|
1029
|
-
);
|
|
1030
|
-
|
|
1031
|
-
return value;
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
1021
|
/**
|
|
1036
1022
|
* @private
|
|
1037
1023
|
*/
|