mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
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
This commit is contained in:
parent
e9eb4d1f3d
commit
17dbc67018
6 changed files with 42 additions and 1 deletions
5
.changeset/pink-beans-cross.md
Normal file
5
.changeset/pink-beans-cross.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix slashes for paths containing non-ASCII characters on Windows
|
|
@ -126,7 +126,7 @@ export function resolveDependency(dep: string, projectRoot: URL) {
|
||||||
* Windows: C:/Users/astro/code/my-project/src/pages/index.astro
|
* Windows: C:/Users/astro/code/my-project/src/pages/index.astro
|
||||||
*/
|
*/
|
||||||
export function viteID(filePath: URL): string {
|
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/`;
|
export const VALID_ID_PREFIX = `/@id/`;
|
||||||
|
|
8
packages/astro/test/fixtures/non-ascii-path/测试/package.json
vendored
Normal file
8
packages/astro/test/fixtures/non-ascii-path/测试/package.json
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"name": "@test/non-ascii-path",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"astro": "workspace:*"
|
||||||
|
}
|
||||||
|
}
|
1
packages/astro/test/fixtures/non-ascii-path/测试/src/pages/index.astro
vendored
Normal file
1
packages/astro/test/fixtures/non-ascii-path/测试/src/pages/index.astro
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<h1>测试 OK</h1>
|
21
packages/astro/test/non-ascii-path.test.js
Normal file
21
packages/astro/test/non-ascii-path.test.js
Normal file
|
@ -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');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -1698,6 +1698,12 @@ importers:
|
||||||
packages/astro/test/fixtures/multiple-renderers/renderers/two:
|
packages/astro/test/fixtures/multiple-renderers/renderers/two:
|
||||||
specifiers: {}
|
specifiers: {}
|
||||||
|
|
||||||
|
packages/astro/test/fixtures/non-ascii-path/测试:
|
||||||
|
specifiers:
|
||||||
|
astro: workspace:*
|
||||||
|
dependencies:
|
||||||
|
astro: link:../../../..
|
||||||
|
|
||||||
packages/astro/test/fixtures/non-html-pages:
|
packages/astro/test/fixtures/non-html-pages:
|
||||||
specifiers:
|
specifiers:
|
||||||
astro: workspace:*
|
astro: workspace:*
|
||||||
|
|
Loading…
Reference in a new issue