Skip to content

Commit 822e4c0

Browse files
authored
[backport] fix: add path normalization to getRelativePath for Windows (#82918) (#83023)
1 parent bb67ca9 commit 822e4c0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/next/src/server/lib/router-utils/route-types-utils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import {
1717
isInterceptionRouteAppPath,
1818
} from '../../../shared/lib/router/utils/interception-routes'
1919

20+
import { normalizePathSep } from '../../../shared/lib/page-path/normalize-path-sep'
21+
2022
interface RouteInfo {
2123
path: string
2224
groups: { [groupName: string]: Group }
@@ -166,10 +168,12 @@ export async function createRouteTypesManifest({
166168
const getRelativePath = (filePath: string) => {
167169
if (validatorFilePath) {
168170
// For validator generation, calculate path relative to validator directory
169-
return path.relative(path.dirname(validatorFilePath), filePath)
171+
return normalizePathSep(
172+
path.relative(path.dirname(validatorFilePath), filePath)
173+
)
170174
}
171175
// For other uses, calculate path relative to project directory
172-
return path.relative(dir, filePath)
176+
return normalizePathSep(path.relative(dir, filePath))
173177
}
174178

175179
const manifest: RouteTypesManifest = {

0 commit comments

Comments
 (0)