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 +------ .../tests/ascii/folder/\303\246\303\270\303\245.md" | 1 + .../tests/ascii/\303\246\303\270\303\245/index.md" | 1 + 4 files changed, 4 insertions(+), 7 deletions(-) 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/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', 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, '/'); 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..a74dbb5279d4 --- /dev/null +++ "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 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