Unverified Commit 6f7ffadc authored by Steven's avatar Steven Committed by GitHub

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 https://github.com/nodejs/nodejs.org/pull/5617 the slash was hardcoded for split that caused the backlash to remain the the `getStaticPaths()` result.

- Fixes #51225 
parent 2cf5d3a8
...@@ -1035,6 +1035,7 @@ export async function buildStaticPaths({ ...@@ -1035,6 +1035,7 @@ export async function buildStaticPaths({
.join('/') .join('/')
: escapePathDelimiters(paramValue as string, true) : escapePathDelimiters(paramValue as string, true)
) )
.replace(/\\/g, '/')
.replace(/(?!^)\/$/, '') .replace(/(?!^)\/$/, '')
encodedBuiltPage = encodedBuiltPage encodedBuiltPage = encodedBuiltPage
...@@ -1044,6 +1045,7 @@ export async function buildStaticPaths({ ...@@ -1044,6 +1045,7 @@ export async function buildStaticPaths({
? (paramValue as string[]).map(encodeURIComponent).join('/') ? (paramValue as string[]).map(encodeURIComponent).join('/')
: encodeURIComponent(paramValue as string) : encodeURIComponent(paramValue as string)
) )
.replace(/\\/g, '/')
.replace(/(?!^)\/$/, '') .replace(/(?!^)\/$/, '')
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment