Skip to content

Commit

Permalink
Remove non-ASCII limitation (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
birjj committed Sep 27, 2022
1 parent b5cdd12 commit b83ed2a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
3 changes: 1 addition & 2 deletions index.js
@@ -1,8 +1,7 @@
export default function slash(path) {
const isExtendedLengthPath = /^\\\\\?\\/.test(path);
const hasNonAscii = /[^\u0000-\u0080]+/.test(path); // eslint-disable-line no-control-regex

if (isExtendedLengthPath || hasNonAscii) {
if (isExtendedLengthPath) {
return path;
}

Expand Down
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -2,7 +2,7 @@

> Convert Windows backslash paths to slash paths: `foo\\bar``foo/bar`
[Forward-slash paths can be used in Windows](http://superuser.com/a/176395/6877) as long as they're not extended-length paths and don't contain any non-ascii characters.
[Forward-slash paths can be used in Windows](http://superuser.com/a/176395/6877) as long as they're not extended-length paths.

This was created since the `path` methods in Node.js outputs `\\` paths on Windows.

Expand Down
6 changes: 1 addition & 5 deletions test.js
Expand Up @@ -4,14 +4,10 @@ import slash from './index.js';
test('convert backwards-slash paths to forward slash paths', t => {
t.is(slash('c:/aaaa\\bbbb'), 'c:/aaaa/bbbb');
t.is(slash('c:\\aaaa\\bbbb'), 'c:/aaaa/bbbb');
t.is(slash('c:\\aaaa\\bbbb\\★'), 'c:/aaaa/bbbb/★');
});

test('not convert extended-length paths', t => {
const path = '\\\\?\\c:\\aaaa\\bbbb';
t.is(slash(path), path);
});

test('not convert paths with Unicode', t => {
const path = 'c:\\aaaa\\bbbb\\★';
t.is(slash(path), path);
});

0 comments on commit b83ed2a

Please sign in to comment.