case sensitivity test

This commit is contained in:
Tj Holowaychuk 2011-11-08 20:29:48 -08:00
parent af46df7eae
commit 1a5636b199
2 changed files with 17 additions and 2 deletions

View File

@ -368,6 +368,5 @@ req.__defineGetter__('stale', function(){
*/
req.__defineGetter__('xhr', function(){
return this.header('X-Requested-With', '')
.toLowerCase() == 'xmlhttprequest';
return 'xmlhttprequest' == this.header('X-Requested-With', '').toLowerCase();
});

View File

@ -20,6 +20,22 @@ describe('req', function(){
})
})
it('should case-insensitive', function(done){
var app = express();
app.use(function(req, res){
req.xhr.should.be.true;
res.end();
});
request(app)
.get('/')
.set('X-Requested-With', 'XMLHttpRequest')
.end(function(res){
done();
})
})
it('should return false otherwise', function(done){
var app = express();