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
1 parent
21914ad
commit e97c2b7
Showing
2 changed files
with
23 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
const absolutePath = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/; | ||
const relativePath = /^\.?\.\//; | ||
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Za-z]:)?[\\|/])/; | ||
const RELATIVE_PATH_REGEX = /^\.?\.\//; | ||
|
||
export function isAbsolute(path: string): boolean { | ||
return absolutePath.test(path); | ||
return ABSOLUTE_PATH_REGEX.test(path); | ||
} | ||
|
||
export function isRelative(path: string): boolean { | ||
return relativePath.test(path); | ||
return RELATIVE_PATH_REGEX.test(path); | ||
} | ||
|
||
const BACKSLASH_REGEX = /\\/g; | ||
|
||
export function normalize(path: string): string { | ||
return path.includes('\\') ? path.replace(/\\/g, '/') : path; | ||
return path.replace(BACKSLASH_REGEX, '/'); | ||
} | ||
|
||
export { basename, dirname, extname, relative, resolve } from 'path'; |