@remix-run/router 0.0.0-experimental-8bb3ffdf → 0.0.0-experimental-d90c8fb3
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 +14 -18
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +14 -18
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +14 -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/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-d90c8fb3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -752,14 +752,14 @@ function matchRoutes(routes, locationArg, basename) {
|
|
|
752
752
|
rankRouteBranches(branches);
|
|
753
753
|
let matches = null;
|
|
754
754
|
for (let i = 0; matches == null && i < branches.length; ++i) {
|
|
755
|
-
matches = matchRouteBranch(branches[i],
|
|
756
755
|
// Incoming pathnames are generally encoded from either window.location
|
|
757
756
|
// or from router.navigate, but we want to match against the unencoded
|
|
758
757
|
// paths in the route definitions. Memory router locations won't be
|
|
759
758
|
// encoded here but there also shouldn't be anything to decode so this
|
|
760
759
|
// should be a safe operation. This avoids needing matchRoutes to be
|
|
761
760
|
// history-aware.
|
|
762
|
-
|
|
761
|
+
let decoded = decodePath(pathname);
|
|
762
|
+
matches = matchRouteBranch(branches[i], decoded);
|
|
763
763
|
}
|
|
764
764
|
return matches;
|
|
765
765
|
}
|
|
@@ -889,7 +889,7 @@ function rankRouteBranches(branches) {
|
|
|
889
889
|
branches.sort((a, b) => a.score !== b.score ? b.score - a.score // Higher score first
|
|
890
890
|
: compareIndexes(a.routesMeta.map(meta => meta.childrenIndex), b.routesMeta.map(meta => meta.childrenIndex)));
|
|
891
891
|
}
|
|
892
|
-
const paramRe =
|
|
892
|
+
const paramRe = /^:[\w-]+$/;
|
|
893
893
|
const dynamicSegmentValue = 3;
|
|
894
894
|
const indexRouteValue = 2;
|
|
895
895
|
const emptySegmentValue = 1;
|
|
@@ -979,7 +979,7 @@ function generatePath(originalPath, params) {
|
|
|
979
979
|
// Apply the splat
|
|
980
980
|
return stringify(params[star]);
|
|
981
981
|
}
|
|
982
|
-
const keyMatch = segment.match(/^:(\w+)(\??)$/);
|
|
982
|
+
const keyMatch = segment.match(/^:([\w-]+)(\??)$/);
|
|
983
983
|
if (keyMatch) {
|
|
984
984
|
const [, key, optional] = keyMatch;
|
|
985
985
|
let param = params[key];
|
|
@@ -1038,7 +1038,7 @@ function matchPath(pattern, pathname) {
|
|
|
1038
1038
|
if (isOptional && !value) {
|
|
1039
1039
|
memo[paramName] = undefined;
|
|
1040
1040
|
} else {
|
|
1041
|
-
memo[paramName] =
|
|
1041
|
+
memo[paramName] = (value || "").replace(/%2F/g, "/");
|
|
1042
1042
|
}
|
|
1043
1043
|
return memo;
|
|
1044
1044
|
}, {});
|
|
@@ -1061,7 +1061,7 @@ function compilePath(path, caseSensitive, end) {
|
|
|
1061
1061
|
let regexpSource = "^" + path.replace(/\/*\*?$/, "") // Ignore trailing / and /*, we'll handle it below
|
|
1062
1062
|
.replace(/^\/*/, "/") // Make sure it has a leading /
|
|
1063
1063
|
.replace(/[\\.*+^${}|()[\]]/g, "\\$&") // Escape special regex chars
|
|
1064
|
-
.replace(/\/:(\w+)(\?)?/g, (_, paramName, isOptional) => {
|
|
1064
|
+
.replace(/\/:([\w-]+)(\?)?/g, (_, paramName, isOptional) => {
|
|
1065
1065
|
params.push({
|
|
1066
1066
|
paramName,
|
|
1067
1067
|
isOptional: isOptional != null
|
|
@@ -1090,22 +1090,14 @@ function compilePath(path, caseSensitive, end) {
|
|
|
1090
1090
|
let matcher = new RegExp(regexpSource, caseSensitive ? undefined : "i");
|
|
1091
1091
|
return [matcher, params];
|
|
1092
1092
|
}
|
|
1093
|
-
function
|
|
1093
|
+
function decodePath(value) {
|
|
1094
1094
|
try {
|
|
1095
|
-
return
|
|
1095
|
+
return value.split("/").map(v => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
|
|
1096
1096
|
} catch (error) {
|
|
1097
1097
|
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
1098
|
return value;
|
|
1099
1099
|
}
|
|
1100
1100
|
}
|
|
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
1101
|
|
|
1110
1102
|
/**
|
|
1111
1103
|
* @private
|
|
@@ -4200,7 +4192,11 @@ async function callLoaderOrAction(type, request, match, matches, manifest, mapRo
|
|
|
4200
4192
|
// Check between word boundaries instead of startsWith() due to the last
|
|
4201
4193
|
// paragraph of https://httpwg.org/specs/rfc9110.html#field.content-type
|
|
4202
4194
|
if (contentType && /\bapplication\/json\b/.test(contentType)) {
|
|
4203
|
-
|
|
4195
|
+
if (result.body == null) {
|
|
4196
|
+
data = null;
|
|
4197
|
+
} else {
|
|
4198
|
+
data = await result.json();
|
|
4199
|
+
}
|
|
4204
4200
|
} else {
|
|
4205
4201
|
data = await result.text();
|
|
4206
4202
|
}
|