Permalink
Browse files

case sensitivity test

  • Loading branch information...
1 parent af46df7 commit 1a5636b1997c960c7dcdea2c83a2981f53e9ee2e @tj tj committed Nov 9, 2011
Showing with 17 additions and 2 deletions.
  1. +1 −2 lib/request.js
  2. +16 −0 test/req.xhr.js
View
@@ -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
@@ -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();

0 comments on commit 1a5636b

Please sign in to comment.