Skip to content

Commit

Permalink
Fix #5806, TypeError on ExternalModule hash.update
Browse files Browse the repository at this point in the history
undefined must be coerced to `false`
  • Loading branch information
STRML committed Oct 11, 2017
1 parent 551ea76 commit c9bad17
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ExternalModule.js
Expand Up @@ -120,7 +120,7 @@ class ExternalModule extends Module {
updateHash(hash) {
hash.update(this.type);
hash.update(JSON.stringify(this.request));
hash.update(JSON.stringify(this.optional));
hash.update(JSON.stringify(Boolean(this.optional)));
super.updateHash(hash);
}
}
Expand Down
28 changes: 28 additions & 0 deletions test/ExternalModule.test.js
Expand Up @@ -340,4 +340,32 @@ module.exports = some/request;`;
hashedText.should.containEql("12345678");
});
});

describe("#updateHash without optional", function() {
let hashedText;
let hash;
beforeEach(function() {
hashedText = "";
hash = {
update: (text) => {
hashedText += text;
}
};
// Note no set of `externalModule.optional`, which crashed externals in 3.7.0
externalModule.id = 12345678;
externalModule.updateHash(hash);
});
it("updates hash with request", function() {
hashedText.should.containEql("some/request");
});
it("updates hash with type", function() {
hashedText.should.containEql("some-type");
});
it("updates hash with optional flag", function() {
hashedText.should.containEql("false");
});
it("updates hash with module id", function() {
hashedText.should.containEql("12345678");
});
});
});

0 comments on commit c9bad17

Please sign in to comment.