Skip to content

Commit

Permalink
fix: normalize backslash in getStaticPaths() for windows (#53876)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
styfle authored Aug 10, 2023
1 parent 2cf5d3a commit 6f7ffad
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,7 @@ export async function buildStaticPaths({
.join('/')
: escapePathDelimiters(paramValue as string, true)
)
.replace(/\\/g, '/')
.replace(/(?!^)\/$/, '')

encodedBuiltPage = encodedBuiltPage
Expand All @@ -1044,6 +1045,7 @@ export async function buildStaticPaths({
? (paramValue as string[]).map(encodeURIComponent).join('/')
: encodeURIComponent(paramValue as string)
)
.replace(/\\/g, '/')
.replace(/(?!^)\/$/, '')
})

Expand Down

0 comments on commit 6f7ffad

Please sign in to comment.