Skip to content

Commit

Permalink
fix: handle non-empty string request (fixes #12)
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Sep 7, 2016
2 parents 804dfa1 + 3b1d847 commit be0254c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/join.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ var absoluteWinRegExp = /^[A-Z]:([\\\/]|$)/i;
var absoluteNixRegExp = /^\//i;

module.exports = function join(path, request) {
if(request == "") return normalize(path);
if(!request) return normalize(path);
if(absoluteWinRegExp.test(request)) return normalize(request.replace(/\//g, "\\"));
if(absoluteNixRegExp.test(request)) return normalize(request);
if(path == "/") return normalize(path + request);
if(absoluteWinRegExp.test(path)) return normalize(path.replace(/\//g, "\\") + "\\" + request.replace(/\//g, "\\"));
if(absoluteNixRegExp.test(path)) return normalize(path + "/" + request);
return normalize(path + "/" + request);
};
};
2 changes: 2 additions & 0 deletions test/MemoryFileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ describe("join", function() {
it("should join paths (weird cases)", function() {
var fs = new MemoryFileSystem();
fs.join("/", "").should.be.eql("/");
// https://github.com/webpack/memory-fs/pull/17
fs.join("/", undefined).should.be.eql("/");
fs.join("/a/b/", "").should.be.eql("/a/b/");
fs.join("/a/b/c", "").should.be.eql("/a/b/c");
fs.join("C:", "").should.be.eql("C:");
Expand Down

0 comments on commit be0254c

Please sign in to comment.