Skip to content

Commit

Permalink
feat: change set status assert, allowing valid custom statuses (#1308)
Browse files Browse the repository at this point in the history
  • Loading branch information
fl0w authored and dead-horse committed Jan 28, 2019
1 parent 72f325b commit b7bfa71
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/response.js
Expand Up @@ -83,8 +83,8 @@ module.exports = {
set status(code) {
if (this.headerSent) return;

assert('number' == typeof code, 'status code must be a number');
assert(statuses[code], `invalid status code: ${code}`);
assert(Number.isInteger(code), 'status code must be a number');
assert(code >= 100 && code <= 999, `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 b7bfa71

Please sign in to comment.