@remix-run/router 1.1.0-pre.0 → 1.1.0
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 +27 -18
- 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/dist/router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.1.0
|
|
2
|
+
* @remix-run/router v1.1.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -653,22 +653,26 @@ function explodeOptionalSegments(path) {
|
|
|
653
653
|
if (rest.length === 0) {
|
|
654
654
|
// Intepret empty string as omitting an optional segment
|
|
655
655
|
// `["one", "", "three"]` corresponds to omitting `:two` from `/one/:two?/three` -> `/one/three`
|
|
656
|
-
return isOptional ? [""
|
|
656
|
+
return isOptional ? [required, ""] : [required];
|
|
657
657
|
}
|
|
658
658
|
|
|
659
659
|
let restExploded = explodeOptionalSegments(rest.join("/"));
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
660
|
+
let result = []; // All child paths with the prefix. Do this for all children before the
|
|
661
|
+
// optional version for all children so we get consistent ordering where the
|
|
662
|
+
// parent optional aspect is preferred as required. Otherwise, we can get
|
|
663
|
+
// child sections interspersed where deeper optional segments are higher than
|
|
664
|
+
// parent optional segments, where for example, /:two would explodes _earlier_
|
|
665
|
+
// then /:one. By always including the parent as required _for all children_
|
|
666
|
+
// first, we avoid this issue
|
|
667
|
+
|
|
668
|
+
result.push(...restExploded.map(subpath => subpath === "" ? required : [required, subpath].join("/"))); // Then if this is an optional value, add all child versions without
|
|
669
|
+
|
|
670
|
+
if (isOptional) {
|
|
671
|
+
result.push(...restExploded);
|
|
672
|
+
} // for absolute paths, ensure `/` instead of empty segment
|
|
673
|
+
|
|
674
|
+
|
|
675
|
+
return result.map(exploded => path.startsWith("/") && exploded === "" ? "/" : exploded);
|
|
672
676
|
}
|
|
673
677
|
|
|
674
678
|
function rankRouteBranches(branches) {
|