Skip to content

Commit 5869175

Browse files
committed
refactor ReplaceNativeSeparator function (utility.ts)
1 parent 0d9d4ef commit 5869175

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

src/utility.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,7 @@ export const Files = function (files: string | string[]): string {
4040
* @return {string} A path with / for directory separator.
4141
*/
4242
export const ReplaceNativeSeparator = function (path: string): string {
43-
let result = path,
44-
next;
45-
46-
while ((next = result.replace(nativeSeparator, '/')) !== result) {
47-
result = next;
48-
}
49-
50-
return result;
43+
return path.replace(new RegExp(`\\${nativeSeparator}`, 'g'), '/');
5144
};
5245

5346
/**

0 commit comments

Comments
 (0)