fix .status= case sensitivity
This commit is contained in:
parent
3439437c18
commit
6fb32165e3
3 changed files with 8 additions and 2 deletions
|
@ -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"
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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(){
|
||||
|
|
Loading…
Reference in a new issue