Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Commit 1880511

Browse files
committed
fix: handle non-empty string request (fixes #12)
2 parents 804dfa1 + 3b1d847 commit 1880511

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/join.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ var absoluteWinRegExp = /^[A-Z]:([\\\/]|$)/i;
44
var absoluteNixRegExp = /^\//i;
55

66
module.exports = function join(path, request) {
7-
if(request == "") return normalize(path);
7+
if(!request) return normalize(path);
88
if(absoluteWinRegExp.test(request)) return normalize(request.replace(/\//g, "\\"));
99
if(absoluteNixRegExp.test(request)) return normalize(request);
1010
if(path == "/") return normalize(path + request);
1111
if(absoluteWinRegExp.test(path)) return normalize(path.replace(/\//g, "\\") + "\\" + request.replace(/\//g, "\\"));
1212
if(absoluteNixRegExp.test(path)) return normalize(path + "/" + request);
1313
return normalize(path + "/" + request);
14-
};
14+
};

test/MemoryFileSystem.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,8 @@ describe("join", function() {
352352
it("should join paths (weird cases)", function() {
353353
var fs = new MemoryFileSystem();
354354
fs.join("/", "").should.be.eql("/");
355+
// https://github.com/webpack/memory-fs/pull/17
356+
fs.join("/", undefined).should.be.eql("/");
355357
fs.join("/a/b/", "").should.be.eql("/a/b/");
356358
fs.join("/a/b/c", "").should.be.eql("/a/b/c");
357359
fs.join("C:", "").should.be.eql("C:");

0 commit comments

Comments
 (0)