fix .status= case sensitivity

This commit is contained in:
TJ Holowaychuk 2013-08-22 21:10:59 -07:00
parent 3439437c18
commit 6fb32165e3
3 changed files with 8 additions and 2 deletions

View File

@ -129,7 +129,7 @@ app.context({
### ctx.status=
Set response status via numeric code or string:
Set response status via numeric code or case-insensitive string:
- 100 "continue"
- 101 "switching protocols"

View File

@ -66,7 +66,7 @@ module.exports = {
set status(val) {
if ('string' == typeof val) {
var n = statuses[val];
var n = statuses[val.toLowerCase()];
if (!n) throw new Error(statusError(val));
val = n;
}

View File

@ -156,6 +156,12 @@ describe('ctx.status=', function(){
ctx.status = 'forbidden';
ctx.status.should.equal(403);
})
it('should be case-insensitive', function(){
var ctx = context();
ctx.status = 'ForBidden';
ctx.status.should.equal(403);
})
})
describe('and invalid', function(){