mirror of
https://github.com/scratchfoundation/restify-cors-middleware.git
synced 2024-11-27 18:05:40 -05:00
Merge pull request #50 from gswalden/patch-1
don't run forEach on undefined
This commit is contained in:
commit
1b0348dec1
2 changed files with 11 additions and 3 deletions
|
@ -36,10 +36,12 @@ var constants = require('./constants.js')
|
|||
module.exports = function (options) {
|
||||
assert.object(options, 'options')
|
||||
assert.optionalArray(options.origins, 'options.origins')
|
||||
if (options.origins) {
|
||||
options.origins.forEach(function (o) {
|
||||
assert.ok(typeof o === 'string' || o instanceof RegExp, o +
|
||||
' is not a valid origin')
|
||||
})
|
||||
}
|
||||
assert.optionalBool(options.credentials, 'options.credentials')
|
||||
assert.optionalArrayOfString(options.allowHeaders, 'options.allowHeaders')
|
||||
assert.optionalArrayOfString(options.exposeHeaders,
|
||||
|
|
|
@ -94,4 +94,10 @@ describe('CORS: simple / actual requests', function () {
|
|||
.expect(200)
|
||||
.end(done)
|
||||
})
|
||||
|
||||
it('Does not throw if "origins" option left undefined', function () {
|
||||
should.doesNotThrow(function createServer () {
|
||||
test.corsServer({})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue