summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2016-12-26 10:20:53 +0100
committertomsmeding <tom.smeding@gmail.com>2016-12-26 10:20:53 +0100
commit852d70f49a03fbfca43e9044f43b586abc37e624 (patch)
treef37ca55d1d0ffd05271982c6547680f57b9880fe
parent605c67c7ec18357370e66cc84725f89df762ca28 (diff)
fix HEAD^
-rwxr-xr-xwebserver.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/webserver.js b/webserver.js
index 62a1719..84864cd 100755
--- a/webserver.js
+++ b/webserver.js
@@ -52,8 +52,7 @@ for(i=0;i<module_list.length;i++){
function requestFile(req,res,path){
- var parsed=url.parse(req.url),basefname=parsed.pathname.slice(2).replace(/\/\.+[^\/]*\//g,"/");
- fname=cmn.rootdir+"/web_files"+basefname;
+ fname=cmn.rootdir+"/web_files"+path;
console.log("Requesting file "+fname);
if(!fs.existsSync(fname)){
res.send("That file does not exist.");
@@ -70,15 +69,15 @@ function requestFile(req,res,path){
});
res.send(
String(fs.readFileSync(cmn.rootdir+"/web_files/dirlisting.html"))
- .replace("<!--DIRDIR-->",basefname)
+ .replace("<!--DIRDIR-->",path)
.replace("[/*LISTINGLISTING*/]",JSON.stringify(items))
);
} else res.send("I don't recognise that file.");
}
-function makeUrlSafe(req){
- var parsed=url.parse(req.url),basefname=parsed.pathname.slice(2).replace(/\/\.+[^\/]*\//g,"/");
- return basefname;
+function makeUrlSafe(req,sliceLength){
+ var parsed=url.parse(req.url);
+ return parsed.pathname.slice(sliceLength).replace(/\/\.+[^\/]*\//g,"/");
}
@@ -94,11 +93,11 @@ app.get("/",function(req,res){
app.get(["/f/univq","/f/univq/*"],cmn.authgen());
app.get("/f/*",function(req,res){
- requestFile(req,res,makeUrlSafe(req));
+ requestFile(req,res,makeUrlSafe(req,2));
});
app.get("/.well-known/*",function(req,res){
- requestFile(req,res,"/well-known"+makeUrlSafe(req));
+ requestFile(req,res,"/well-known"+makeUrlSafe(req,12));
});
["o","k","rip","rip2"].forEach(function(target){