Passthrough fails with index: false #10

Closed
wants to merge 3 commits into
from
View
@@ -44,6 +44,9 @@ var mount = st({
dot: false, // default: return 403 for any url with a dot-file part
dot: true, // allow dot-files to be fetched normally
+
+ passthrough: true, // calls next instead of returning a 404 error
+ passthrough: false, // returns a 404 when a file or an index is not found
})
// with bare node.js
View
3 st.js
@@ -222,6 +222,9 @@ Mount.prototype.serve = function (req, res, next) {
res.setHeader('etag', etag)
if (stat.isDirectory()) {
+ if (this.opt.passthrough === true && this._index === false) {
+ return next();
+ }
return this.index(p, req, res)
}
View
@@ -4,7 +4,7 @@ var util = require('util')
var path = require('path')
var opts = util._extend({
- autoindex: true,
+ index: false,
path: path.resolve(__dirname, './fixtures'),
url: '/',
passthrough: true
@@ -21,12 +21,15 @@ test('call next() if passthrough is set', function (t) {
setHeader: function () {},
end: function () {}
}
- t.plan(1)
- function next() {
- t.ok(true, "next called")
- t.end()
- }
- mount(req, res, next)
+ t.plan(2)
+ mount(req, res, function () {
+ t.ok(true, "next called with nonexistant file");
+ req.url='/';
+ mount(req, res, function () {
+ t.ok(true, "next called without indexing")
+ t.end()
+ });
+ })
})
var opts2 = util._extend({