mirror of
https://github.com/scratchfoundation/restify-cors-middleware.git
synced 2024-12-19 04:12:25 -05:00
don't run forEach on undefined. closes #44
This commit is contained in:
parent
c7eb8a84f3
commit
fcba706227
1 changed files with 5 additions and 3 deletions
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue