-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
54 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,52 @@ | ||
function unix_absolute(path: string) { | ||
const re = /^\/[^\\/](?!\.{1,2}($|\/))((?!\/[./](\/|$))\/?.)*\/?(?<!\/\.{1,1})$/i | ||
const re = /^\/[^\\/](?!\.{1,2}($|\/))((?!\/[./](\/|$))\/?.)*\/?(?<!\/\.{1,1})$/i; | ||
|
||
return re.test(path) | ||
return re.test(path); | ||
} | ||
|
||
function unix_relative(path: string) { | ||
const re = /^.{1,2}\/(?:.{2}|\w)*$/i | ||
return re.test(path) | ||
const re = /^.{1,2}\/(?:.{2}|\w)*$/i; | ||
return re.test(path); | ||
} | ||
|
||
function win_absolute(path: string) { | ||
const re = /^(?:(?:[a-z]:\\)|\\)(((?![<>:"/\\|?*]).)+(?:(?<![ .])\\)?)*$/i | ||
return re.test(path) | ||
const re = /^(?:(?:[a-z]:\\)|\\)(((?![<>:"/\\|?*]).)+(?:(?<![ .])\\)?)*$/i; | ||
return re.test(path); | ||
} | ||
|
||
function unix_valid(path: string) { | ||
return unix_absolute(path) || unix_relative(path) | ||
return unix_absolute(path) || unix_relative(path); | ||
} | ||
|
||
function win_relative(path: string) { | ||
const re = | ||
/^(?:(?:[a-z]:)|[a-z0-9]|\.{2}\\)(?:(?:(?:(?![<>:"/\\|?*]).)|(?:\.{2}))+(?:(?<![ .]{3})\\)?)*$/i | ||
return re.test(path) | ||
const re = /^(?:(?:[a-z]:)|[a-z0-9]|\.{2}\\)(?:(?:(?:(?![<>:"/\\|?*]).)|(?:\.{2}))+(?:(?<![ .]{3})\\)?)*$/i; | ||
return re.test(path); | ||
} | ||
|
||
function win_valid(path: string) { | ||
return win_absolute(path) || win_relative(path) | ||
return win_absolute(path) || win_relative(path); | ||
} | ||
|
||
export function isPath(path: string) { | ||
return win_valid(path) || unix_valid(path) | ||
return win_valid(path) || unix_valid(path); | ||
} | ||
|
||
export function isAbsolute(path: string) { | ||
return win_absolute(path) || unix_absolute(path) | ||
return win_absolute(path) || unix_absolute(path); | ||
} | ||
|
||
export function relative(path: string) { | ||
return win_relative(path) || unix_relative(path) | ||
return win_relative(path) || unix_relative(path); | ||
} | ||
|
||
export function absolute(path: string) { | ||
return win_absolute(path) || unix_absolute(path) | ||
return win_absolute(path) || unix_absolute(path); | ||
} | ||
|
||
export function win(path: string) { | ||
return win_valid(path) | ||
return win_valid(path); | ||
} | ||
|
||
export function unix(path: string) { | ||
return unix_valid(path) | ||
return unix_valid(path); | ||
} |