diff --git a/lib/index.js b/lib/index.js index 9bd1f94..9fa9d4b 100755 --- a/lib/index.js +++ b/lib/index.js @@ -212,7 +212,7 @@ internals.BoomOutput = class { constructor(statusCode, headers) { this.statusCode = statusCode; - this.headers = headers ? Hoek.clone(headers, { prototype: false, symbols: false }) : {}; + this.headers = typeof headers === 'object' ? Hoek.clone(headers, { prototype: false, symbols: false }) : {}; } }; diff --git a/test/index.js b/test/index.js index 832af91..b1db734 100755 --- a/test/index.js +++ b/test/index.js @@ -90,6 +90,14 @@ describe('Boom', () => { expect(headers).to.equal({ custom: ['yes'] }); }); + it('ignores non-object headers option', () => { + + const err = new Boom.Boom('fail', { statusCode: 400, headers: true }); + expect(err.output.payload.message).to.equal('fail'); + expect(err.output.statusCode).to.equal(400); + expect(err.output.headers).to.equal({}); + }); + it('throws when statusCode is invalid', () => { expect(() => {