Fix 404 when non-english character presents in URL

This commit is contained in:
Kirigaya Kazuto 2019-01-19 22:29:46 +08:00
parent a874a96592
commit 61fd000d8d

2
app.js
View File

@ -105,7 +105,7 @@ async function RebuildSite() {
async function request_handler(req,res) { async function request_handler(req,res) {
let obj=url.parse(req.url,true) let obj=url.parse(req.url,true)
if(req.method=="GET") { if(req.method=="GET") {
let normPath=path.normalize(obj.pathname) let normPath=path.normalize(decodeURI(obj.pathname))
let localPath=path.join(ROOT_DIR,normPath) let localPath=path.join(ROOT_DIR,normPath)
try { try {
let stats=await promisify(fs.stat)(localPath) let stats=await promisify(fs.stat)(localPath)