astro
astro copied to clipboard
Fix slashes for paths containing non-ASCII characters on Windows.
Changes
Related issue: #4689
The slash
library cannot handle paths containing non-ASCII characters, so we need to manually replace \
with /
.
Examples
fileURLToPath(filePath)
// -> C:\Codes\测试\my-astro-site\src\pages\index.astro
slash(fileURLToPath(filePath))
// -> C:\Codes\测试\my-astro-site\src\pages\index.astro
slash(fileURLToPath(filePath)).replace(/\\/g, '/')
// -> C:/Codes/测试/my-astro-site/src/pages/index.astro ✅
Testing
Test locally only.
Docs
None.