Skip to content

Commit 6f7ffad

Browse files
authored
fix: normalize backslash in getStaticPaths() for windows (#53876)
This normalizes the backslash for windows users who accidentally use `\` in the request paths instead of the expected `/`. For example, in nodejs/nodejs.org#5617 the slash was hardcoded for split that caused the backlash to remain the the `getStaticPaths()` result. - Fixes #51225
1 parent 2cf5d3a commit 6f7ffad

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

packages/next/src/build/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,7 @@ export async function buildStaticPaths({
10351035
.join('/')
10361036
: escapePathDelimiters(paramValue as string, true)
10371037
)
1038+
.replace(/\\/g, '/')
10381039
.replace(/(?!^)\/$/, '')
10391040

10401041
encodedBuiltPage = encodedBuiltPage
@@ -1044,6 +1045,7 @@ export async function buildStaticPaths({
10441045
? (paramValue as string[]).map(encodeURIComponent).join('/')
10451046
: encodeURIComponent(paramValue as string)
10461047
)
1048+
.replace(/\\/g, '/')
10471049
.replace(/(?!^)\/$/, '')
10481050
})
10491051

0 commit comments

Comments
 (0)