diff options
author | tomsmeding <tom.smeding@gmail.com> | 2018-02-18 11:33:09 +0100 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2018-02-18 11:33:09 +0100 |
commit | 68328af342f437c62e64094475e17c669f6f11c5 (patch) | |
tree | 977ee0ff4a69e79c87e7e0fbf492e6eb69f563ea | |
parent | 117141c6250862a0c62695e846daac3df362d873 (diff) |
Fix HEAD^
-rwxr-xr-x | webserver.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/webserver.js b/webserver.js index 554dc03..c59cd9f 100755 --- a/webserver.js +++ b/webserver.js @@ -76,7 +76,7 @@ for(i=0;i<module_list.length;i++){ } -function requestFile(req,res,listdirs,path){ +function requestFile(req,res,listdirs,path,origpath){ fname=cmn.rootdir+"/web_files"+path; console.log("Requesting file "+fname); if(!fs.existsSync(fname)){ @@ -107,7 +107,8 @@ function requestFile(req,res,listdirs,path){ .replace("[/*LISTINGLISTING*/]",JSON.stringify(items)) ); } else if(stats.isDirectory()&&fs.readdirSync(fname).indexOf("index.html")!=-1){ - res.redirect(301, node_path.join(fname,"index.html")); + if(origpath[origpath.length-1]!="/")origpath+="/"; + res.redirect(301,origpath+"index.html"); } else { res.status(404).send("That file does not exist."); return; @@ -134,16 +135,16 @@ app.get("/",function(req,res){ app.get(["/f/univq","/f/univq/*"],cmn.authgen()); app.get(["/f","/f/*"],function(req,res){ - requestFile(req,res,false,unescape(makeUrlSafe(req,2))); + requestFile(req,res,false,unescape(makeUrlSafe(req,2)),req.url); }); app.get(["/ff","/ff/*"],cmn.authgen()); app.get(["/ff","/ff/*"],function(req,res){ - requestFile(req,res,true,unescape(makeUrlSafe(req,3))); + requestFile(req,res,true,unescape(makeUrlSafe(req,3)),req.url); }); app.get("/.well-known/*",function(req,res){ - requestFile(req,res,false,"/well-known"+unescape(makeUrlSafe(req,12))); + requestFile(req,res,false,"/well-known"+unescape(makeUrlSafe(req,12)),req.url); }); app.get("/google*.html",function(req,res){ |