diff --git a/lib/normalize.js b/lib/normalize.js index 6519c8b..a83449a 100644 --- a/lib/normalize.js +++ b/lib/normalize.js @@ -10,7 +10,12 @@ module.exports = function normalize(path) { result.push(part); absolutePathStart = 2; } else if(sep) { - result.push(part[0]); + // UNC paths on Windows begin with a double backslash. + if (i === 1 && parts[0].length === 0 && part === "\\\\") { + result.push(part); + } else { + result.push(part[0]); + } } else if(part === "..") { switch(result.length) { case 0: diff --git a/test/MemoryFileSystem.js b/test/MemoryFileSystem.js index 0d6428b..7eceffb 100644 --- a/test/MemoryFileSystem.js +++ b/test/MemoryFileSystem.js @@ -358,6 +358,7 @@ describe("normalize", function() { fs.normalize("C:\\a\\b\\\c\\..\\..").should.be.eql("C:\\a"); fs.normalize("C:\\a\\b\\d\\..\\c\\..\\..").should.be.eql("C:\\a"); fs.normalize("C:\\a\\b\\d\\\\.\\\\.\\c\\.\\..").should.be.eql("C:\\a\\b\\d"); + fs.normalize("\\\\remote-computer\\c$\\file").should.be.eql("\\\\remote-computer\\c$\\file"); }); }); describe("pathToArray", function() {