expressjs/serve-static — pull request #18 by jjmerino (2014-10-08 07:58:03+00:00)
Title: Avoid redirect loop if no index is provided

**Problem**
The library falls into an infinite redirect loop when index option is set to false and the url matches a directory.
**How to reproduce**
Serve a folder using serve static and disable index: `{index:false}` , try to access any subdirectory. You will get an infinite redirect.**Example**: `localhost/public/folder` will turn into `localhost/public/folder////////////////////`.

**Explanation**
When index option is set to false, the `send` library will, by default, send a 403 response if the requested resource is a directory. This will not happen if there are any `on('redirect',...)` listeners, as the `send` library will delegate to the listeners.

Unfortunately, the `serve-static` library handles the redirection but does not check to see if the resource ends with `/`. This results in the library redirecting to `originalUrl+='/' ` over and over again. Producing an infinite redirect loop when index is set to false and the user requests a directory.

**Proposed Solution**
The problem has been fixed by assuming a desired behaviour similar to that of the `send` library and the rest of `serve-static`, i.e, 403 for root directory, and 404 (ignore and forward) for subdirectories, to ensure un intrusiveness when using as a middleware.
2 passing tests have been added to the specs for both cases.