Skip to content

Commit 8c0a31e

Browse files
committed
dont validate undefineds
1 parent 23c124a commit 8c0a31e

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

test/library.spec.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,4 +315,9 @@ describe('validate options', function () {
315315
expect(results[0].correctTerm).to.be.equal('allowlist');
316316
expect(results[1].correctTerm).to.be.equal('modulesDir');
317317
});
318+
it('should no identify undefineds', function () {
319+
var results = utils.validateOptions({ allowlist: undefined, modulesdir: [] });
320+
expect(results.length).to.be.equal(1);
321+
expect(results[0].correctTerm).to.be.equal('modulesDir');
322+
});
318323
});

utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ exports.containsPattern = function containsPattern(arr, val) {
9898
};
9999

100100
exports.validateOptions = function (options) {
101+
options = options || {};
101102
var results = [];
102103
var mistakes = {
103104
allowlist: ['allowslist', 'whitelist', 'allow'],
@@ -112,7 +113,7 @@ exports.validateOptions = function (options) {
112113
return optionName && optionName.toLowerCase();
113114
});
114115
Object.keys(mistakes).forEach(function (correctTerm) {
115-
if (options[correctTerm] === undefined) {
116+
if (!options.hasOwnProperty(correctTerm)) {
116117
mistakes[correctTerm]
117118
.concat(correctTerm.toLowerCase())
118119
.forEach(function (mistake) {

0 commit comments

Comments
 (0)