@remix-run/router 1.1.0-pre.0 → 1.1.0-pre.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 +18 -14
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +18 -14
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +18 -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/package.json +1 -1
- package/utils.ts +26 -16
package/CHANGELOG.md
CHANGED
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.1.0-pre.
|
|
2
|
+
* @remix-run/router v1.1.0-pre.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -691,22 +691,26 @@ function explodeOptionalSegments(path) {
|
|
|
691
691
|
if (rest.length === 0) {
|
|
692
692
|
// Intepret empty string as omitting an optional segment
|
|
693
693
|
// `["one", "", "three"]` corresponds to omitting `:two` from `/one/:two?/three` -> `/one/three`
|
|
694
|
-
return isOptional ? [""
|
|
694
|
+
return isOptional ? [required, ""] : [required];
|
|
695
695
|
}
|
|
696
696
|
|
|
697
697
|
let restExploded = explodeOptionalSegments(rest.join("/"));
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
698
|
+
let result = []; // All child paths with the prefix. Do this for all children before the
|
|
699
|
+
// optional version for all children so we get consistent ordering where the
|
|
700
|
+
// parent optional aspect is preferred as required. Otherwise, we can get
|
|
701
|
+
// child sections interspersed where deeper optional segments are higher than
|
|
702
|
+
// parent optional segments, where for example, /:two would explodes _earlier_
|
|
703
|
+
// then /:one. By always including the parent as required _for all children_
|
|
704
|
+
// first, we avoid this issue
|
|
705
|
+
|
|
706
|
+
result.push(...restExploded.map(subpath => subpath === "" ? required : [required, subpath].join("/"))); // Then if this is an optional value, add all child versions without
|
|
707
|
+
|
|
708
|
+
if (isOptional) {
|
|
709
|
+
result.push(...restExploded);
|
|
710
|
+
} // for absolute paths, ensure `/` instead of empty segment
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
return result.map(exploded => path.startsWith("/") && exploded === "" ? "/" : exploded);
|
|
710
714
|
}
|
|
711
715
|
|
|
712
716
|
function rankRouteBranches(branches) {
|