astro icon indicating copy to clipboard operation
astro copied to clipboard

Fix slashes for paths containing non-ASCII characters on Windows.

Open Lifeni opened this issue 2 years ago • 4 comments

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.

Lifeni avatar Sep 10 '22 15:09 Lifeni