Permalink
Browse files

Merge branch 'master' of github.com:senchalabs/connect

  • Loading branch information...
2 parents a155d36 + 22592cd commit 3cb10794fc2c1329d0079594c566a44d4935e5ca @tj tj committed May 18, 2012
Showing with 13 additions and 8 deletions.
  1. +2 −4 lib/middleware/compress.js
  2. +1 −2 lib/middleware/csrf.js
  3. +2 −2 lib/middleware/static.js
  4. +8 −0 test/static.js
View
6 lib/middleware/compress.js
@@ -26,8 +26,7 @@ exports.methods = {
*/
exports.filter = function(req, res){
- var type = res.getHeader('Content-Type') || '';
- return type.match(/json|text|javascript/);
+ return /json|text|javascript/.test(res.getHeader('Content-Type'));
};
/**
@@ -41,8 +40,7 @@ exports.filter = function(req, res){
* replace the default logic of:
*
* exports.filter = function(req, res){
- * var type = res.getHeader('Content-Type') || '';
- * return type.match(/json|text|javascript/);
+ * return /json|text|javascript/.test(res.getHeader('Content-Type'));
* };
*
* Options:
View
3 lib/middleware/csrf.js
@@ -8,8 +8,7 @@
* Module dependencies.
*/
-var utils = require('../utils')
- , crypto = require('crypto');
+var utils = require('../utils');
/**
* Anti CSRF:
View
4 lib/middleware/static.js
@@ -150,10 +150,10 @@ var send = exports.send = function(req, res, next, options){
// mime type
type = mime.lookup(path);
- // ignore ENOENT
+ // ignore ENOENT, ENAMETOOLONG and ENOTDIR
if (err) {
if (fn) return fn(err);
- return ('ENOENT' == err.code || 'ENAMETOOLONG' == err.code)
+ return ('ENOENT' == err.code || 'ENAMETOOLONG' == err.code || 'ENOTDIR' == err.code)
? next()
: next(err);
// redirect directory in case index.html is present
View
8 test/static.js
@@ -254,6 +254,14 @@ describe('connect.static()', function(){
})
})
+ describe('on ENOTDIR', function(){
+ it('should next()', function(done) {
+ app.request()
+ .get('/todo.txt/a.php')
+ .expect(404, done);
+ })
+ })
+
describe('when mounted', function(){
it('should redirect relative to the originalUrl', function(done){
var app = connect();

0 comments on commit 3cb1079

Please sign in to comment.