@remix-run/router 1.14.1 → 1.14.2
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 +7 -0
- package/dist/router.cjs.js +9 -5
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +9 -5
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +9 -5
- 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 +9 -6
package/package.json
CHANGED
package/router.ts
CHANGED
|
@@ -4098,7 +4098,11 @@ async function callLoaderOrAction(
|
|
|
4098
4098
|
// Check between word boundaries instead of startsWith() due to the last
|
|
4099
4099
|
// paragraph of https://httpwg.org/specs/rfc9110.html#field.content-type
|
|
4100
4100
|
if (contentType && /\bapplication\/json\b/.test(contentType)) {
|
|
4101
|
-
|
|
4101
|
+
if (result.body == null) {
|
|
4102
|
+
data = null;
|
|
4103
|
+
} else {
|
|
4104
|
+
data = await result.json();
|
|
4105
|
+
}
|
|
4102
4106
|
} else {
|
|
4103
4107
|
data = await result.text();
|
|
4104
4108
|
}
|
package/utils.ts
CHANGED
|
@@ -685,7 +685,7 @@ function rankRouteBranches(branches: RouteBranch[]): void {
|
|
|
685
685
|
);
|
|
686
686
|
}
|
|
687
687
|
|
|
688
|
-
const paramRe =
|
|
688
|
+
const paramRe = /^:[\w-]+$/;
|
|
689
689
|
const dynamicSegmentValue = 3;
|
|
690
690
|
const indexRouteValue = 2;
|
|
691
691
|
const emptySegmentValue = 1;
|
|
@@ -822,7 +822,7 @@ export function generatePath<Path extends string>(
|
|
|
822
822
|
return stringify(params[star]);
|
|
823
823
|
}
|
|
824
824
|
|
|
825
|
-
const keyMatch = segment.match(/^:(\w+)(\??)$/);
|
|
825
|
+
const keyMatch = segment.match(/^:([\w-]+)(\??)$/);
|
|
826
826
|
if (keyMatch) {
|
|
827
827
|
const [, key, optional] = keyMatch;
|
|
828
828
|
let param = params[key as PathParam<Path>];
|
|
@@ -967,10 +967,13 @@ function compilePath(
|
|
|
967
967
|
.replace(/\/*\*?$/, "") // Ignore trailing / and /*, we'll handle it below
|
|
968
968
|
.replace(/^\/*/, "/") // Make sure it has a leading /
|
|
969
969
|
.replace(/[\\.*+^${}|()[\]]/g, "\\$&") // Escape special regex chars
|
|
970
|
-
.replace(
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
970
|
+
.replace(
|
|
971
|
+
/\/:([\w-]+)(\?)?/g,
|
|
972
|
+
(_: string, paramName: string, isOptional) => {
|
|
973
|
+
params.push({ paramName, isOptional: isOptional != null });
|
|
974
|
+
return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
|
|
975
|
+
}
|
|
976
|
+
);
|
|
974
977
|
|
|
975
978
|
if (path.endsWith("*")) {
|
|
976
979
|
params.push({ paramName: "*" });
|