Skip to content

Commit

Permalink
Correctly insert "index.html" for url paths ending in "/" on Windows
Browse files Browse the repository at this point in the history
Since 'normalize' changes all the forward slashes to backward slashes on Windows, we need to check in the path ends in "/" BEFORE we call 'normalize'.
  • Loading branch information
chowey committed Nov 3, 2011
1 parent 81d3b6b commit acd7aba
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/middleware/static.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/*!
* Connect - staticProvider
* Copyright(c) 2010 Sencha Inc.
Expand Down Expand Up @@ -109,7 +108,10 @@ var send = exports.send = function(req, res, next, options){

// when root is not given, consider .. malicious
if (!root && ~path.indexOf('..')) return next(403);


// index.html support
if ('/' == path[path.length - 1]) path += 'index.html';

// join / normalize from optional root dir
path = normalize(join(root, path));

Expand All @@ -118,9 +120,6 @@ var send = exports.send = function(req, res, next, options){
? fn(new Error('Forbidden'))
: next(403);

// index.html support
if ('/' == path[path.length - 1]) path += 'index.html';

// "hidden" file
if (!hidden && '.' == basename(path)[0]) return next();

Expand Down

0 comments on commit acd7aba

Please sign in to comment.