@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix-run/router",
3
- "version": "1.14.1",
3
+ "version": "1.14.2",
4
4
  "description": "Nested/Data-driven/Framework-agnostic Routing",
5
5
  "keywords": [
6
6
  "remix",
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
- data = await result.json();
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 = /^:\w+$/;
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(/\/:(\w+)(\?)?/g, (_: string, paramName: string, isOptional) => {
971
- params.push({ paramName, isOptional: isOptional != null });
972
- return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
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: "*" });