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 authored and slorber committed Oct 28, 2022
1 parent 086906d commit 824a0f3
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dogfood test for https://github.com/facebook/docusaurus/pull/8137
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dogfood test for https://github.com/facebook/docusaurus/pull/8137

0 comments on commit 824a0f3

Please sign in to comment.