feat(nodeserver): if index.html exists, serve it instead of directory listing

This commit is contained in:
Vojta Jina 2011-10-12 18:23:20 -07:00 committed by Igor Minar
parent afc81b554e
commit 02332107e5

View file

@ -107,7 +107,15 @@ StaticServlet.prototype.handleRequest = function(req, res) {
if (err)
return self.sendMissing_(req, res, path);
if (stat.isDirectory())
return self.sendDirectory_(req, res, path);
return fs.stat(path + 'index.html', function(err, stat) {
// send index.html if exists
if (!err)
return self.sendFile_(req, res, path + 'index.html');
// list files otherwise
return self.sendDirectory_(req, res, path);
});
return self.sendFile_(req, res, path);
});
};