Skip to content

Commit

Permalink
Merge branch 'dev' into logan/flat-routes-no-splat-anywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
mcansh authored Jan 5, 2023
2 parents e736078 + 5663081 commit 11e0437
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
6 changes: 6 additions & 0 deletions .changeset/curvy-mangos-heal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"remix": patch
"@remix-run/dev": patch
---

update flat-routes invalid character error message to include link to React Router proposal
17 changes: 9 additions & 8 deletions packages/remix-dev/config/flat-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,22 +126,23 @@ export function getRouteSegments(routeId: string) {
let pushRouteSegment = (routeSegment: string) => {
if (!routeSegment) return;

if (rawRouteSegment.includes("*")) {
let notSupportedInRR = (segment: string, char: string) => {
throw new Error(
`Route segment "${rawRouteSegment}" for "${routeId}" cannot contain "*"`
`Route segment "${segment}" for "${routeId}" cannot contain "${char}".\n` +
`If this is something you need, upvote this proposal for React Router https://github.com/remix-run/react-router/discussions/9822.`
);
};

if (rawRouteSegment.includes("*")) {
return notSupportedInRR(rawRouteSegment, "*");
}

if (rawRouteSegment.includes(":")) {
throw new Error(
`Route segment "${rawRouteSegment}" for "${routeId}" cannot contain ":"`
);
return notSupportedInRR(rawRouteSegment, ":");
}

if (rawRouteSegment.includes("/")) {
throw new Error(
`Route segment "${routeSegment}" for "${routeId}" cannot contain "/"`
);
return notSupportedInRR(routeSegment, "/");
}
routeSegments.push(routeSegment);
};
Expand Down

0 comments on commit 11e0437

Please sign in to comment.