diff options
author | 2022-09-23 02:33:28 +0800 | |
---|---|---|
committer | 2022-09-22 14:33:28 -0400 | |
commit | 17dbc670186188ba418a1c8842d9349ee557fa2a (patch) | |
tree | 3af796afface8370a7ed540bb0968357b1a78d7e /packages | |
parent | e9eb4d1f3dd6b2d40fd86ae25a38d9363139e7c1 (diff) | |
download | astro-17dbc670186188ba418a1c8842d9349ee557fa2a.tar.gz astro-17dbc670186188ba418a1c8842d9349ee557fa2a.tar.zst astro-17dbc670186188ba418a1c8842d9349ee557fa2a.zip |
Fix slashes for paths containing non-ASCII characters on Windows. (#4712)
* Fix slashes for paths containing non-ASCII characters on Windows.
* Add non-ASCII path test
* Fix slashes in pnpm-lock.yaml
Diffstat (limited to 'packages')
4 files changed, 31 insertions, 1 deletions
diff --git a/packages/astro/src/core/util.ts b/packages/astro/src/core/util.ts index 17fbc41a6..07b087493 100644 --- a/packages/astro/src/core/util.ts +++ b/packages/astro/src/core/util.ts @@ -126,7 +126,7 @@ export function resolveDependency(dep: string, projectRoot: URL) { * Windows: C:/Users/astro/code/my-project/src/pages/index.astro */ export function viteID(filePath: URL): string { - return slash(fileURLToPath(filePath) + filePath.search); + return slash(fileURLToPath(filePath) + filePath.search).replace(/\\/g, '/'); } export const VALID_ID_PREFIX = `/@id/`; diff --git a/packages/astro/test/fixtures/non-ascii-path/测试/package.json b/packages/astro/test/fixtures/non-ascii-path/测试/package.json new file mode 100644 index 000000000..0c38763be --- /dev/null +++ b/packages/astro/test/fixtures/non-ascii-path/测试/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/non-ascii-path", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/non-ascii-path/测试/src/pages/index.astro b/packages/astro/test/fixtures/non-ascii-path/测试/src/pages/index.astro new file mode 100644 index 000000000..57b148ac2 --- /dev/null +++ b/packages/astro/test/fixtures/non-ascii-path/测试/src/pages/index.astro @@ -0,0 +1 @@ +<h1>测试 OK</h1>
\ No newline at end of file diff --git a/packages/astro/test/non-ascii-path.test.js b/packages/astro/test/non-ascii-path.test.js new file mode 100644 index 000000000..5fb947e9e --- /dev/null +++ b/packages/astro/test/non-ascii-path.test.js @@ -0,0 +1,21 @@ +import { expect } from 'chai'; +import * as cheerio from 'cheerio'; +import { loadFixture } from './test-utils.js'; + +describe('Non-ASCII Path Test', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ root: './fixtures/non-ascii-path/测试/' }); + await fixture.build(); + }); + + describe('build', () => { + it('Can load page', async () => { + const html = await fixture.readFile(`/index.html`); + const $ = cheerio.load(html); + + expect($('h1').text()).to.equal('测试 OK'); + }); + }); +}); |