From df60ebdc5f5768c1ade4c3445d9334006021fd9e Mon Sep 17 00:00:00 2001 From: Johan Fagerberg Date: Tue, 27 Sep 2022 11:44:21 +0200 Subject: [PATCH 1/4] fix: remove non-ASCII limitation for path normalization See https://github.com/sindresorhus/slash/issues/19 for discussion on limitation in the originating package This updates the integrated function to match sindresorhus/slash after https://github.com/sindresorhus/slash/pull/20 --- packages/docusaurus-utils/src/pathUtils.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/docusaurus-utils/src/pathUtils.ts b/packages/docusaurus-utils/src/pathUtils.ts index 381cfd1faa2e..d8d221a17e1b 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, '/'); From 29280009cfd484651980434da083bb85dd996d1b Mon Sep 17 00:00:00 2001 From: Johan Fagerberg Date: Tue, 27 Sep 2022 11:46:48 +0200 Subject: [PATCH 2/4] tests: update posixPath tests with non-ASCII support --- packages/docusaurus-utils/src/__tests__/pathUtils.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/docusaurus-utils/src/__tests__/pathUtils.test.ts b/packages/docusaurus-utils/src/__tests__/pathUtils.test.ts index 6059d2946d08..3927b09a7a0a 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', From 19d3507b2a4731527f0476dbf7c6b213e7aba222 Mon Sep 17 00:00:00 2001 From: sebastienlorber Date: Fri, 7 Oct 2022 13:18:23 +0200 Subject: [PATCH 3/4] Add a bit of ASCII dogfooding just in case Windows CI could crash? --- .../_docs tests/tests/ascii/folder/\303\246\303\270\303\245.md" | 0 .../_docs tests/tests/ascii/\303\246\303\270\303\245/index.md" | 1 + 2 files changed, 1 insertion(+) create mode 100644 "website/_dogfooding/_docs tests/tests/ascii/folder/\303\246\303\270\303\245.md" create mode 100644 "website/_dogfooding/_docs tests/tests/ascii/\303\246\303\270\303\245/index.md" diff --git "a/website/_dogfooding/_docs tests/tests/ascii/folder/\303\246\303\270\303\245.md" "b/website/_dogfooding/_docs tests/tests/ascii/folder/\303\246\303\270\303\245.md" new file mode 100644 index 000000000000..e69de29bb2d1 diff --git "a/website/_dogfooding/_docs tests/tests/ascii/\303\246\303\270\303\245/index.md" "b/website/_dogfooding/_docs tests/tests/ascii/\303\246\303\270\303\245/index.md" new file mode 100644 index 000000000000..a74dbb5279d4 --- /dev/null +++ "b/website/_dogfooding/_docs tests/tests/ascii/\303\246\303\270\303\245/index.md" @@ -0,0 +1 @@ +Dogfood test for https://github.com/facebook/docusaurus/pull/8137 From 70d31a31cea96cf9bb8575816dd8726f8d777dbf Mon Sep 17 00:00:00 2001 From: sebastienlorber Date: Fri, 7 Oct 2022 13:18:58 +0200 Subject: [PATCH 4/4] Add a bit of ASCII dogfooding just in case Windows CI could crash? --- .../_docs tests/tests/ascii/folder/\303\246\303\270\303\245.md" | 1 + 1 file changed, 1 insertion(+) diff --git "a/website/_dogfooding/_docs tests/tests/ascii/folder/\303\246\303\270\303\245.md" "b/website/_dogfooding/_docs tests/tests/ascii/folder/\303\246\303\270\303\245.md" index e69de29bb2d1..a74dbb5279d4 100644 --- "a/website/_dogfooding/_docs tests/tests/ascii/folder/\303\246\303\270\303\245.md" +++ "b/website/_dogfooding/_docs tests/tests/ascii/folder/\303\246\303\270\303\245.md" @@ -0,0 +1 @@ +Dogfood test for https://github.com/facebook/docusaurus/pull/8137