Skip to content

Commit

Permalink
fix(utils): remove non-ASCII limitation for path normalization (#8137)
Browse files Browse the repository at this point in the history
  • Loading branch information
birjj committed Oct 7, 2022
1 parent efbd0cb commit 6c8af03
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/docusaurus-utils/src/__tests__/pathUtils.test.ts
Expand Up @@ -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',
Expand Down
7 changes: 1 addition & 6 deletions packages/docusaurus-utils/src/pathUtils.ts
Expand Up @@ -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, '/');
Expand Down
@@ -0,0 +1 @@
Dogfood test for https://github.com/facebook/docusaurus/pull/8137
@@ -0,0 +1 @@
Dogfood test for https://github.com/facebook/docusaurus/pull/8137

0 comments on commit 6c8af03

Please sign in to comment.