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