@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.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
|
*
|
|
@@ -417,6 +417,10 @@ function getUrlBasedHistory(getLocation, createHref, validateLocation, options)
|
|
|
417
417
|
// See https://bugzilla.mozilla.org/show_bug.cgi?id=878297
|
|
418
418
|
let base = window.location.origin !== "null" ? window.location.origin : window.location.href;
|
|
419
419
|
let href = typeof to === "string" ? to : createPath(to);
|
|
420
|
+
// Treating this as a full URL will strip any trailing spaces so we need to
|
|
421
|
+
// pre-encode them since they might be part of a matching splat param from
|
|
422
|
+
// an ancestor route
|
|
423
|
+
href = href.replace(/ $/, "%20");
|
|
420
424
|
invariant(base, "No window.location.(origin|href) available to create URL for href: " + href);
|
|
421
425
|
return new URL(href, base);
|
|
422
426
|
}
|
|
@@ -523,14 +527,14 @@ function matchRoutes(routes, locationArg, basename) {
|
|
|
523
527
|
rankRouteBranches(branches);
|
|
524
528
|
let matches = null;
|
|
525
529
|
for (let i = 0; matches == null && i < branches.length; ++i) {
|
|
526
|
-
matches = matchRouteBranch(branches[i],
|
|
527
530
|
// Incoming pathnames are generally encoded from either window.location
|
|
528
531
|
// or from router.navigate, but we want to match against the unencoded
|
|
529
532
|
// paths in the route definitions. Memory router locations won't be
|
|
530
533
|
// encoded here but there also shouldn't be anything to decode so this
|
|
531
534
|
// should be a safe operation. This avoids needing matchRoutes to be
|
|
532
535
|
// history-aware.
|
|
533
|
-
|
|
536
|
+
let decoded = decodePath(pathname);
|
|
537
|
+
matches = matchRouteBranch(branches[i], decoded);
|
|
534
538
|
}
|
|
535
539
|
return matches;
|
|
536
540
|
}
|
|
@@ -789,7 +793,7 @@ function matchPath(pattern, pathname) {
|
|
|
789
793
|
if (isOptional && !value) {
|
|
790
794
|
memo[paramName] = undefined;
|
|
791
795
|
} else {
|
|
792
|
-
memo[paramName] =
|
|
796
|
+
memo[paramName] = (value || "").replace(/%2F/g, "/");
|
|
793
797
|
}
|
|
794
798
|
return memo;
|
|
795
799
|
}, {});
|
|
@@ -841,22 +845,14 @@ function compilePath(path, caseSensitive, end) {
|
|
|
841
845
|
let matcher = new RegExp(regexpSource, caseSensitive ? undefined : "i");
|
|
842
846
|
return [matcher, params];
|
|
843
847
|
}
|
|
844
|
-
function
|
|
848
|
+
function decodePath(value) {
|
|
845
849
|
try {
|
|
846
|
-
return
|
|
850
|
+
return value.split("/").map(v => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
|
|
847
851
|
} catch (error) {
|
|
848
852
|
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 + ")."));
|
|
849
853
|
return value;
|
|
850
854
|
}
|
|
851
855
|
}
|
|
852
|
-
function safelyDecodeURIComponent(value, paramName) {
|
|
853
|
-
try {
|
|
854
|
-
return decodeURIComponent(value);
|
|
855
|
-
} catch (error) {
|
|
856
|
-
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 + ")."));
|
|
857
|
-
return value;
|
|
858
|
-
}
|
|
859
|
-
}
|
|
860
856
|
/**
|
|
861
857
|
* @private
|
|
862
858
|
*/
|