浏览代码

now redirects to <path>/ when serving a directory's index.html

master
mortie 7 年前
父节点
当前提交
8f2f0886c1
共有 1 个文件被更改,包括 10 次插入2 次删除
  1. 10
    2
      js/static.js

+ 10
- 2
js/static.js 查看文件

@@ -93,9 +93,17 @@ module.exports = function(root, before) {
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");
}

// Send the file
send(path);

正在加载...
取消
保存