@remix-run/router 0.0.0-experimental-8bb3ffdf → 0.0.0-experimental-114cf0b7
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 +19 -9
- package/dist/router.cjs.js +18 -18
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +18 -18
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +18 -18
- 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/router.ts +5 -1
- package/utils.ts +23 -34
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# `@remix-run/router`
|
|
2
2
|
|
|
3
|
+
## 1.14.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix bug where dashes were not picked up in dynamic parameter names ([#11160](https://github.com/remix-run/react-router/pull/11160))
|
|
8
|
+
- Do not attempt to deserialize empty JSON responses ([#11164](https://github.com/remix-run/react-router/pull/11164))
|
|
9
|
+
|
|
10
|
+
## 1.14.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Fix bug with `route.lazy` not working correctly on initial SPA load when `v7_partialHydration` is specified ([#11121](https://github.com/remix-run/react-router/pull/11121))
|
|
15
|
+
- Fix bug preventing revalidation from occurring for persisted fetchers unmounted during the `submitting` phase ([#11102](https://github.com/remix-run/react-router/pull/11102))
|
|
16
|
+
- De-dup relative path logic in `resolveTo` ([#11097](https://github.com/remix-run/react-router/pull/11097))
|
|
17
|
+
|
|
3
18
|
## 1.14.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
|
@@ -149,7 +164,7 @@
|
|
|
149
164
|
<BrowserRouter>
|
|
150
165
|
<Routes>
|
|
151
166
|
<Route path="dashboard">
|
|
152
|
-
<Route path="*" element={<Dashboard />} />
|
|
167
|
+
<Route index path="*" element={<Dashboard />} />
|
|
153
168
|
</Route>
|
|
154
169
|
</Routes>
|
|
155
170
|
</BrowserRouter>
|
|
@@ -185,7 +200,7 @@
|
|
|
185
200
|
|
|
186
201
|
### Patch Changes
|
|
187
202
|
|
|
188
|
-
- Revert the `useResolvedPath` fix for splat routes due to a large number of applications that were relying on the buggy behavior (see https://github.com/remix-run/react-router/issues/11052#issuecomment-1836589329). We plan to re-introduce this fix behind a future flag in the next minor version. ([#11078](https://github.com/remix-run/react-router/pull/11078))
|
|
203
|
+
- Revert the `useResolvedPath` fix for splat routes due to a large number of applications that were relying on the buggy behavior (see <https://github.com/remix-run/react-router/issues/11052#issuecomment-1836589329>). We plan to re-introduce this fix behind a future flag in the next minor version. ([#11078](https://github.com/remix-run/react-router/pull/11078))
|
|
189
204
|
|
|
190
205
|
## 1.13.0
|
|
191
206
|
|
|
@@ -665,11 +680,6 @@ function Comp() {
|
|
|
665
680
|
|
|
666
681
|
This is the first stable release of `@remix-run/router`, which provides all the underlying routing and data loading/mutation logic for `react-router`. You should _not_ be using this package directly unless you are authoring a routing library similar to `react-router`.
|
|
667
682
|
|
|
668
|
-
For an overview of the features provided by `react-router`, we recommend you go check out the [docs]
|
|
669
|
-
|
|
670
|
-
For an overview of the features provided by `@remix-run/router`, please check out the [`README`][remix-router-readme].
|
|
683
|
+
For an overview of the features provided by `react-router`, we recommend you go check out the [docs](https://reactrouter.com), especially the [feature overview](https://reactrouter.com/start/overview) and the [tutorial](https://reactrouter.com/start/tutorial).
|
|
671
684
|
|
|
672
|
-
[
|
|
673
|
-
[rr-feature-overview]: https://reactrouter.com/start/overview
|
|
674
|
-
[rr-tutorial]: https://reactrouter.com/start/tutorial
|
|
675
|
-
[remix-router-readme]: https://github.com/remix-run/react-router/blob/main/packages/router/README.md
|
|
685
|
+
For an overview of the features provided by `@remix-run/router`, please check out the [`README`](./README.md).
|
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v0.0.0-experimental-
|
|
2
|
+
* @remix-run/router v0.0.0-experimental-114cf0b7
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -496,6 +496,10 @@ function getUrlBasedHistory(getLocation, createHref, validateLocation, options)
|
|
|
496
496
|
// See https://bugzilla.mozilla.org/show_bug.cgi?id=878297
|
|
497
497
|
let base = window.location.origin !== "null" ? window.location.origin : window.location.href;
|
|
498
498
|
let href = typeof to === "string" ? to : createPath(to);
|
|
499
|
+
// Treating this as a full URL will strip any trailing spaces so we need to
|
|
500
|
+
// pre-encode them since they might be part of a matching splat param from
|
|
501
|
+
// an ancestor route
|
|
502
|
+
href = href.replace(/ $/, "%20");
|
|
499
503
|
invariant(base, "No window.location.(origin|href) available to create URL for href: " + href);
|
|
500
504
|
return new URL(href, base);
|
|
501
505
|
}
|
|
@@ -752,14 +756,14 @@ function matchRoutes(routes, locationArg, basename) {
|
|
|
752
756
|
rankRouteBranches(branches);
|
|
753
757
|
let matches = null;
|
|
754
758
|
for (let i = 0; matches == null && i < branches.length; ++i) {
|
|
755
|
-
matches = matchRouteBranch(branches[i],
|
|
756
759
|
// Incoming pathnames are generally encoded from either window.location
|
|
757
760
|
// or from router.navigate, but we want to match against the unencoded
|
|
758
761
|
// paths in the route definitions. Memory router locations won't be
|
|
759
762
|
// encoded here but there also shouldn't be anything to decode so this
|
|
760
763
|
// should be a safe operation. This avoids needing matchRoutes to be
|
|
761
764
|
// history-aware.
|
|
762
|
-
|
|
765
|
+
let decoded = decodePath(pathname);
|
|
766
|
+
matches = matchRouteBranch(branches[i], decoded);
|
|
763
767
|
}
|
|
764
768
|
return matches;
|
|
765
769
|
}
|
|
@@ -889,7 +893,7 @@ function rankRouteBranches(branches) {
|
|
|
889
893
|
branches.sort((a, b) => a.score !== b.score ? b.score - a.score // Higher score first
|
|
890
894
|
: compareIndexes(a.routesMeta.map(meta => meta.childrenIndex), b.routesMeta.map(meta => meta.childrenIndex)));
|
|
891
895
|
}
|
|
892
|
-
const paramRe =
|
|
896
|
+
const paramRe = /^:[\w-]+$/;
|
|
893
897
|
const dynamicSegmentValue = 3;
|
|
894
898
|
const indexRouteValue = 2;
|
|
895
899
|
const emptySegmentValue = 1;
|
|
@@ -979,7 +983,7 @@ function generatePath(originalPath, params) {
|
|
|
979
983
|
// Apply the splat
|
|
980
984
|
return stringify(params[star]);
|
|
981
985
|
}
|
|
982
|
-
const keyMatch = segment.match(/^:(\w+)(\??)$/);
|
|
986
|
+
const keyMatch = segment.match(/^:([\w-]+)(\??)$/);
|
|
983
987
|
if (keyMatch) {
|
|
984
988
|
const [, key, optional] = keyMatch;
|
|
985
989
|
let param = params[key];
|
|
@@ -1038,7 +1042,7 @@ function matchPath(pattern, pathname) {
|
|
|
1038
1042
|
if (isOptional && !value) {
|
|
1039
1043
|
memo[paramName] = undefined;
|
|
1040
1044
|
} else {
|
|
1041
|
-
memo[paramName] =
|
|
1045
|
+
memo[paramName] = (value || "").replace(/%2F/g, "/");
|
|
1042
1046
|
}
|
|
1043
1047
|
return memo;
|
|
1044
1048
|
}, {});
|
|
@@ -1061,7 +1065,7 @@ function compilePath(path, caseSensitive, end) {
|
|
|
1061
1065
|
let regexpSource = "^" + path.replace(/\/*\*?$/, "") // Ignore trailing / and /*, we'll handle it below
|
|
1062
1066
|
.replace(/^\/*/, "/") // Make sure it has a leading /
|
|
1063
1067
|
.replace(/[\\.*+^${}|()[\]]/g, "\\$&") // Escape special regex chars
|
|
1064
|
-
.replace(/\/:(\w+)(\?)?/g, (_, paramName, isOptional) => {
|
|
1068
|
+
.replace(/\/:([\w-]+)(\?)?/g, (_, paramName, isOptional) => {
|
|
1065
1069
|
params.push({
|
|
1066
1070
|
paramName,
|
|
1067
1071
|
isOptional: isOptional != null
|
|
@@ -1090,22 +1094,14 @@ function compilePath(path, caseSensitive, end) {
|
|
|
1090
1094
|
let matcher = new RegExp(regexpSource, caseSensitive ? undefined : "i");
|
|
1091
1095
|
return [matcher, params];
|
|
1092
1096
|
}
|
|
1093
|
-
function
|
|
1097
|
+
function decodePath(value) {
|
|
1094
1098
|
try {
|
|
1095
|
-
return
|
|
1099
|
+
return value.split("/").map(v => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
|
|
1096
1100
|
} catch (error) {
|
|
1097
1101
|
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 + ")."));
|
|
1098
1102
|
return value;
|
|
1099
1103
|
}
|
|
1100
1104
|
}
|
|
1101
|
-
function safelyDecodeURIComponent(value, paramName) {
|
|
1102
|
-
try {
|
|
1103
|
-
return decodeURIComponent(value);
|
|
1104
|
-
} catch (error) {
|
|
1105
|
-
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 + ")."));
|
|
1106
|
-
return value;
|
|
1107
|
-
}
|
|
1108
|
-
}
|
|
1109
1105
|
|
|
1110
1106
|
/**
|
|
1111
1107
|
* @private
|
|
@@ -4200,7 +4196,11 @@ async function callLoaderOrAction(type, request, match, matches, manifest, mapRo
|
|
|
4200
4196
|
// Check between word boundaries instead of startsWith() due to the last
|
|
4201
4197
|
// paragraph of https://httpwg.org/specs/rfc9110.html#field.content-type
|
|
4202
4198
|
if (contentType && /\bapplication\/json\b/.test(contentType)) {
|
|
4203
|
-
|
|
4199
|
+
if (result.body == null) {
|
|
4200
|
+
data = null;
|
|
4201
|
+
} else {
|
|
4202
|
+
data = await result.json();
|
|
4203
|
+
}
|
|
4204
4204
|
} else {
|
|
4205
4205
|
data = await result.text();
|
|
4206
4206
|
}
|