mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-29 10:17:55 +02:00
fix(utils): remove non-ASCII limitation for path normalization (#8137)
This commit is contained in:
parent
efbd0cbd40
commit
6c8af03f51
4 changed files with 4 additions and 7 deletions
|
@ -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',
|
||||
|
|
|
@ -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, '/');
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Dogfood test for https://github.com/facebook/docusaurus/pull/8137
|
1
website/_dogfooding/_docs tests/tests/ascii/æøå/index.md
Normal file
1
website/_dogfooding/_docs tests/tests/ascii/æøå/index.md
Normal file
|
@ -0,0 +1 @@
|
|||
Dogfood test for https://github.com/facebook/docusaurus/pull/8137
|
Loading…
Add table
Reference in a new issue