Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Passthrough fails with index: false #10

Closed
wants to merge 3 commits into from

3 participants

Christian Howe Pavan Kumar Sunkara Isaac Z. Schlueter
Christian Howe

Added tests and fixed them.

Pavan Kumar Sunkara

@isaacs Can you pull this as soon as possible?

And also consider publishing a new minor version?

Christian Howe

This documentation is long overdue. :D

Isaac Z. Schlueter isaacs closed this pull request from a commit November 08, 2012
Christian Howe Fix passthrough behavior when index:false
close #10

added failing test for passthrough with index: false

fix failing test for passthrough with index: false
2d8c0f1
Isaac Z. Schlueter isaacs closed this in 2d8c0f1 November 08, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
3  README.md
Source Rendered
@@ -44,6 +44,9 @@ var mount = st({
44 44
 
45 45
   dot: false, // default: return 403 for any url with a dot-file part
46 46
   dot: true, // allow dot-files to be fetched normally
  47
+
  48
+  passthrough: true, // calls next instead of returning a 404 error
  49
+  passthrough: false, // returns a 404 when a file or an index is not found
47 50
 })
48 51
 
49 52
 // with bare node.js
3  st.js
@@ -222,6 +222,9 @@ Mount.prototype.serve = function (req, res, next) {
222 222
       res.setHeader('etag', etag)
223 223
 
224 224
       if (stat.isDirectory()) {
  225
+        if (this.opt.passthrough === true && this._index === false) {
  226
+          return next();
  227
+        }
225 228
         return this.index(p, req, res)
226 229
       }
227 230
 
17  test/passthrough.js
@@ -4,7 +4,7 @@ var util = require('util')
4 4
 var path = require('path')
5 5
 
6 6
 var opts = util._extend({
7  
-  autoindex: true,
  7
+  index: false,
8 8
   path: path.resolve(__dirname, './fixtures'),
9 9
   url: '/',
10 10
   passthrough: true
@@ -21,12 +21,15 @@ test('call next() if passthrough is set', function (t) {
21 21
     setHeader: function () {},
22 22
     end: function () {}
23 23
   }
24  
-  t.plan(1)
25  
-  function next() {
26  
-    t.ok(true, "next called")
27  
-    t.end()
28  
-  }
29  
-  mount(req, res, next)
  24
+  t.plan(2)
  25
+  mount(req, res, function () {
  26
+    t.ok(true, "next called with nonexistant file");
  27
+    req.url='/';
  28
+    mount(req, res, function () {
  29
+      t.ok(true, "next called without indexing")
  30
+      t.end()
  31
+    });
  32
+  })
30 33
 })
31 34
 
32 35
 var opts2 = util._extend({
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.