Comparing version 0.1.1 to 0.1.2
@@ -24,3 +24,3 @@ var path = require('path'), | ||
pathname = decodeURI(parsed.pathname), | ||
file = path.normalize(path.join(root, parsed.pathname)); | ||
file = path.normalize(path.join(root, pathname)); | ||
@@ -42,17 +42,13 @@ // Set common headers. | ||
// retry for ./404.html, if that's not there then return 404 | ||
// TODO: Make this pluggable/configurable. | ||
var handler = (typeof next === 'function' && !autoIndex) | ||
? next | ||
: function () { | ||
showDir(file, pathname, stat, cache)(req, res); | ||
}; | ||
middleware({ | ||
url: '/404.html', | ||
statusCode: 404 // Override the response | ||
}, res, function (req, res, next) { | ||
if (req.statusCode == 404) { | ||
// This means we're already trying ./404.html | ||
status[404](res, next); | ||
}); | ||
} | ||
else { | ||
// Try for ./404.html | ||
middleware({ | ||
url: '/404.html', | ||
statusCode: 404 // Override the response status code | ||
}, res, next); | ||
} | ||
} | ||
@@ -69,3 +65,3 @@ else if (err) { | ||
: function () { | ||
showDir(file, pathname, stat, cache)(req, res); | ||
showDir(root, pathname, stat, cache)(req, res); | ||
}; | ||
@@ -72,0 +68,0 @@ |
@@ -5,3 +5,3 @@ { | ||
"description": "A simple static file server middleware that works with both Express and Flatiron", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"homepage": "https://github.com/jesusabdullah/node-ecstatic", | ||
@@ -8,0 +8,0 @@ "repository": { |
208665
349