mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 23:00:30 +00:00
19 lines
515 B
TypeScript
19 lines
515 B
TypeScript
|
import path from 'path';
|
||
|
|
||
|
const win32SepRegex = /\\/g;
|
||
|
const posixSepRegex = /\//g;
|
||
|
|
||
|
export function convertToPosixSep(filePath: string) {
|
||
|
return filePath.replace(win32SepRegex, path.posix.sep);
|
||
|
}
|
||
|
|
||
|
export function convertToOsSep(filePath: string) {
|
||
|
// is windows, so convert posix sep to windows sep
|
||
|
if (path.sep === path.win32.sep) {
|
||
|
return filePath.replace(posixSepRegex, path.win32.sep);
|
||
|
}
|
||
|
|
||
|
// is posix, so convert win32 sep to posix sep
|
||
|
return filePath.replace(win32SepRegex, path.posix.sep);
|
||
|
}
|