return; | return; | ||||
} | } | ||||
// If it's a directory, we want the index.html file | |||||
if (stat.isDirectory()) | |||||
// If it's a directory, we want the index.html file, | |||||
// or redirect to <pathname>/ | |||||
if (stat.isDirectory()) { | |||||
if (pn[pn.length - 1] !== "/") { | |||||
res.writeHead(302, { location: pn + "/" }); | |||||
res.end(); | |||||
return; | |||||
} | |||||
path = pathlib.join(path, "index.html"); | path = pathlib.join(path, "index.html"); | ||||
} | |||||
// Send the file | // Send the file | ||||
send(path); | send(path); |