Skip to content

Commit

Permalink
refactor: use regex to avoid UNC check
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Sep 17, 2016
1 parent 4070531 commit a66aa97
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions lib/normalize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var doubleSlackUNCRegExp = /^\\\\/;
var doubleSlashWinRegExp = /\\+/g;
var doubleSlashWinRegExp = /(?!^)\\+/g;;
var doubleSlashNixRegExp = /\/+/g;
var currentDirectoryWinMiddleRegExp = /\\(\.\\)+/;
var currentDirectoryWinEndRegExp = /\\\.$/;
Expand Down Expand Up @@ -35,13 +34,7 @@ module.exports = function normalize(path) {
path = path.replace(parentDirectoryNixEndRegExp2, "");
path = path.replace(parentDirectoryNixEndRegExp3, "/");

var unc = doubleSlackUNCRegExp.test(path);

path = path.replace(doubleSlashWinRegExp, "\\").replace(doubleSlashNixRegExp, "/")

if (unc) {
path = '\\' + path;
}
path = path.replace(doubleSlashWinRegExp, "\\").replace(doubleSlashNixRegExp, "/");

return path;
};

0 comments on commit a66aa97

Please sign in to comment.