Skip to content

Commit 67220e3

Browse files
authored
feat(vscode): normalizing middleware parent as route path (#835)
1 parent 82238b1 commit 67220e3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

extensions/vscode/src/test/suite/utils/dart-frog-structure.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ suite("normalizeRoutePath", () => {
8888
normalizeRoutePath(`${dartFrogPath}/tennis.dart`, dartFrogPath),
8989
"/"
9090
);
91+
assert.equal(
92+
normalizeRoutePath(
93+
`${dartFrogPath}/routes/a/b/_middleware.dart`,
94+
dartFrogPath
95+
),
96+
"a/b"
97+
);
9198
});
9299
});
93100

extensions/vscode/src/utils/dart-frog-structure.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ export function normalizeRoutePath(
3737
const isFile = parsedRelativePath.ext !== "";
3838
if (!isFile) {
3939
routePath = relativePath;
40-
} else if (parsedRelativePath.name === "index") {
40+
} else if (
41+
parsedRelativePath.name === "index" ||
42+
parsedRelativePath.name === "_middleware"
43+
) {
4144
routePath = parsedRelativePath.dir;
4245
} else {
4346
routePath = path.join(parsedRelativePath.dir, parsedRelativePath.name);

0 commit comments

Comments
 (0)