don't run forEach on undefined. closes #44

This commit is contained in:
Greg Walden 2017-10-18 17:13:00 -04:00 committed by GitHub
parent c7eb8a84f3
commit fcba706227

View file

@ -36,10 +36,12 @@ var constants = require('./constants.js')
module.exports = function (options) { module.exports = function (options) {
assert.object(options, 'options') assert.object(options, 'options')
assert.optionalArray(options.origins, 'options.origins') assert.optionalArray(options.origins, 'options.origins')
if (options.origins) {
options.origins.forEach(function (o) { options.origins.forEach(function (o) {
assert.ok(typeof o === 'string' || o instanceof RegExp, o + assert.ok(typeof o === 'string' || o instanceof RegExp, o +
' is not a valid origin') ' is not a valid origin')
}) })
}
assert.optionalBool(options.credentials, 'options.credentials') assert.optionalBool(options.credentials, 'options.credentials')
assert.optionalArrayOfString(options.allowHeaders, 'options.allowHeaders') assert.optionalArrayOfString(options.allowHeaders, 'options.allowHeaders')
assert.optionalArrayOfString(options.exposeHeaders, assert.optionalArrayOfString(options.exposeHeaders,