Skip to content

Commit

Permalink
Merge pull request #35 from hyperparabolic/master
Browse files Browse the repository at this point in the history
Update dependencies
  • Loading branch information
nlf authored Mar 25, 2020
2 parents 301a18c + 96f000f commit 220f3b6
Show file tree
Hide file tree
Showing 6 changed files with 914 additions and 518 deletions.
40 changes: 17 additions & 23 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,37 +353,31 @@ internals.addHeaders = function (request, h) {

internals.validateOptions = function (options) {

let result;
const { error, value } = Schema.validate(options);

Schema.validate(options, (err, value) => {

if (err) {
result = err;
return;
}

internals.arrayValues.forEach((key) => {
if (error) {
return error;
}

if (value[key] !== undefined) {
if (key === 'sandbox' && value[key] === true) {
return;
}
internals.arrayValues.forEach((key) => {

value[key] = value[key].map((val) => {
if (value[key] !== undefined) {
if (key === 'sandbox' && value[key] === true) {
return;
}

if (internals.needQuotes.indexOf(val) !== -1) {
return `'${val}'`;
}
value[key] = value[key].map((val) => {

return val;
});
}
});
if (internals.needQuotes.indexOf(val) !== -1) {
return `'${val}'`;
}

result = value;
return val;
});
}
});

return result;
return value;
};

exports.plugin = {
Expand Down
2 changes: 1 addition & 1 deletion lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ module.exports = Joi.object({
styleSrc: Joi.array().items(Joi.string()).single().default(['self'])
.when('generateNonces', { is: [false, 'script'], then: Joi.array().items(Joi.string().valid('strict-dynamic').forbidden()) }),
workerSrc: Joi.array().items(Joi.string()).single().default(['self']),
generateNonces: Joi.alternatives().try([Joi.boolean(), Joi.string().valid('script', 'style')]).default(true)
generateNonces: Joi.alternatives().try(Joi.boolean(), Joi.string().valid('script', 'style')).default(true)
}).with('reportOnly', 'reportUri');
Loading

0 comments on commit 220f3b6

Please sign in to comment.