From 6c8af03f513891c7ff6ab049480e274cc12d119a Mon Sep 17 00:00:00 2001 From: Johan Fagerberg Date: Fri, 7 Oct 2022 13:35:12 +0200 Subject: [PATCH] fix(utils): remove non-ASCII limitation for path normalization (#8137) --- packages/docusaurus-utils/src/__tests__/pathUtils.test.ts | 2 +- packages/docusaurus-utils/src/pathUtils.ts | 7 +------ .../_dogfooding/_docs tests/tests/ascii/folder/æøå.md | 1 + .../_dogfooding/_docs tests/tests/ascii/æøå/index.md | 1 + 4 files changed, 4 insertions(+), 7 deletions(-) create mode 100644 website/_dogfooding/_docs tests/tests/ascii/folder/æøå.md create mode 100644 website/_dogfooding/_docs tests/tests/ascii/æøå/index.md diff --git a/packages/docusaurus-utils/src/__tests__/pathUtils.test.ts b/packages/docusaurus-utils/src/__tests__/pathUtils.test.ts index 6059d2946d..3927b09a7a 100644 --- a/packages/docusaurus-utils/src/__tests__/pathUtils.test.ts +++ b/packages/docusaurus-utils/src/__tests__/pathUtils.test.ts @@ -156,7 +156,7 @@ describe('posixPath', () => { it('works', () => { const asserts: {[key: string]: string} = { 'c:/aaaa\\bbbb': 'c:/aaaa/bbbb', - 'c:\\aaaa\\bbbb\\★': 'c:\\aaaa\\bbbb\\★', + 'c:\\aaaa\\bbbb\\★': 'c:/aaaa/bbbb/★', '\\\\?\\c:\\aaaa\\bbbb': '\\\\?\\c:\\aaaa\\bbbb', 'c:\\aaaa\\bbbb': 'c:/aaaa/bbbb', 'foo\\bar': 'foo/bar', diff --git a/packages/docusaurus-utils/src/pathUtils.ts b/packages/docusaurus-utils/src/pathUtils.ts index 381cfd1faa..d8d221a17e 100644 --- a/packages/docusaurus-utils/src/pathUtils.ts +++ b/packages/docusaurus-utils/src/pathUtils.ts @@ -58,12 +58,7 @@ export function shortName(str: string): string { export function posixPath(str: string): string { const isExtendedLengthPath = str.startsWith('\\\\?\\'); - // Forward slashes are only valid Windows paths when they don't contain non- - // ascii characters. - // eslint-disable-next-line no-control-regex - const hasNonAscii = /[^\u0000-\u0080]+/.test(str); - - if (isExtendedLengthPath || hasNonAscii) { + if (isExtendedLengthPath) { return str; } return str.replace(/\\/g, '/'); diff --git a/website/_dogfooding/_docs tests/tests/ascii/folder/æøå.md b/website/_dogfooding/_docs tests/tests/ascii/folder/æøå.md new file mode 100644 index 0000000000..a74dbb5279 --- /dev/null +++ b/website/_dogfooding/_docs tests/tests/ascii/folder/æøå.md @@ -0,0 +1 @@ +Dogfood test for https://github.com/facebook/docusaurus/pull/8137 diff --git a/website/_dogfooding/_docs tests/tests/ascii/æøå/index.md b/website/_dogfooding/_docs tests/tests/ascii/æøå/index.md new file mode 100644 index 0000000000..a74dbb5279 --- /dev/null +++ b/website/_dogfooding/_docs tests/tests/ascii/æøå/index.md @@ -0,0 +1 @@ +Dogfood test for https://github.com/facebook/docusaurus/pull/8137