Browse files

Fixing #14 by checking for directory before every possible pass

  • Loading branch information...
1 parent dc3c8e4 commit d83d4f1fa05ea726b404da9ef9d5bf9b8feb5016 @tomgco committed Dec 21, 2011
Showing with 9 additions and 9 deletions.
  1. +8 −8 lib/staticGzip.js
  2. +1 −1 package.json
View
16 lib/staticGzip.js
@@ -152,19 +152,19 @@ exports = module.exports = function staticGzip(dirPath, options){
contentType = contentType + (charset ? '; charset=' + charset : '');
acceptEncoding = req.headers['accept-encoding'] || '';
- if (!contentTypeMatch.test(contentType)) {
- return pass(filename);
- }
-
- if (!~acceptEncoding.indexOf('gzip')) {
- return pass(filename);
- }
-
//This is storing in memory for the moment, need to think what the best way to do this.
//Check file is not a directory
fs.stat(filename, function(err, stat) {
if (err || stat.isDirectory()) {
+ return pass(req.url);
+ }
+
+ if (!contentTypeMatch.test(contentType)) {
+ return pass(filename);
+ }
+
+ if (!~acceptEncoding.indexOf('gzip')) {
return pass(filename);
}
View
2 package.json
@@ -1,6 +1,6 @@
{
"name" : "gzippo",
-"version" : "0.1.0",
+"version" : "0.1.1",
"author" : "Tom Gallacher",
"description" : "Gzip middleware for Connect using the native zlib library in node >= 0.6",
"homepage" : "http://www.tomg.co/gzippo",

0 comments on commit d83d4f1

Please sign in to comment.