Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

  • Loading branch information...
commit 3cb10794fc2c1329d0079594c566a44d4935e5ca 2 parents a155d36 + 22592cd
@tj tj authored
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();
Please sign in to comment.
Something went wrong with that request. Please try again.