Skip to content

Commit

Permalink
change set status assert, use statuses when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
fl0w committed Jan 27, 2019
1 parent 72f325b commit 6d7e949
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/response.js
Expand Up @@ -84,7 +84,7 @@ module.exports = {
if (this.headerSent) return;

assert('number' == typeof code, 'status code must be a number');
assert(statuses[code], `invalid status code: ${code}`);
assert(/^[0-9]{3}$/.test(code), `invalid status code: ${code}`);
this._explicitStatus = true;
this.res.statusCode = code;
if (this.req.httpVersionMajor < 2) this.res.statusMessage = statuses[code];
Expand Down
4 changes: 2 additions & 2 deletions test/response/status.js
Expand Up @@ -24,8 +24,8 @@ describe('res.status=', () => {
describe('and invalid', () => {
it('should throw', () => {
assert.throws(() => {
response().status = 999;
}, /invalid status code: 999/);
response().status = 99;
}, /invalid status code: 99/);
});
});

Expand Down

0 comments on commit 6d7e949

Please sign in to comment.