Skip to content

Commit

Permalink
fix(remix-dev): Use normalized file path when analyzing flat routes (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelgmcd authored Mar 13, 2023
1 parent 889e452 commit 4867713
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@
- michaeldebetaz
- michaeldeboey
- michaelfriedman
- michaelgmcd
- michaelhelvey
- michaseel
- mikeybinnswebdesign
Expand Down
14 changes: 14 additions & 0 deletions packages/remix-dev/__tests__/flat-routes-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,20 @@ describe("flatRoutes", () => {
);
});

test("nested index files", () => {
let testFiles = ["routes/_index/index.tsx", "routes/_index/utils.ts"];

let routeManifest = flatRoutesUniversal(
APP_DIR,
testFiles.map((file) => path.join(APP_DIR, normalizePath(file)))
);

let routes = Object.values(routeManifest);

expect(routes).toHaveLength(1);
expect(consoleError).not.toHaveBeenCalled();
});

test("folder/route.tsx matching folder.tsx", () => {
// we'll add file manually before running the tests
let testFiles = ["routes/dashboard.tsx", "routes/dashboard/route.tsx"];
Expand Down
2 changes: 1 addition & 1 deletion packages/remix-dev/config/flat-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ function getRouteMap(
function isRouteModuleFile(filePath: string) {
// flat files only need correct extension
let normalizedFilePath = normalizeSlashes(filePath);
let isFlatFile = !filePath.includes(path.posix.sep);
let isFlatFile = !normalizedFilePath.includes(path.posix.sep);
let hasExt = routeModuleExts.includes(path.extname(filePath));
if (isFlatFile) return hasExt;
let basename = normalizedFilePath.slice(0, -path.extname(filePath).length);
Expand Down

0 comments on commit 4867713

Please sign in to comment.