From 605c67c7ec18357370e66cc84725f89df762ca28 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Mon, 26 Dec 2016 10:16:39 +0100 Subject: Prepare for more files in /.well-known --- webserver.js | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/webserver.js b/webserver.js index 77283af..62a1719 100755 --- a/webserver.js +++ b/webserver.js @@ -51,18 +51,7 @@ for(i=0;i>-->/,whatpulse["keys"]) - .replace(//,whatpulse["clicks"]) - ); -}); - -app.get(["/f/univq","/f/univq/*"],cmn.authgen()); - -app.get("/f/*",function(req,res){ +function requestFile(req,res,path){ var parsed=url.parse(req.url),basefname=parsed.pathname.slice(2).replace(/\/\.+[^\/]*\//g,"/"); fname=cmn.rootdir+"/web_files"+basefname; console.log("Requesting file "+fname); @@ -85,6 +74,31 @@ app.get("/f/*",function(req,res){ .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; +} + + + +app.get("/",function(req,res){ + res.send( + String(fs.readFileSync(cmn.serverdir+"/index.html")) + .replace(//,whatpulse["keys"]) + .replace(//,whatpulse["clicks"]) + ); +}); + +app.get(["/f/univq","/f/univq/*"],cmn.authgen()); + +app.get("/f/*",function(req,res){ + requestFile(req,res,makeUrlSafe(req)); +}); + +app.get("/.well-known/*",function(req,res){ + requestFile(req,res,"/well-known"+makeUrlSafe(req)); }); ["o","k","rip","rip2"].forEach(function(target){ @@ -100,10 +114,6 @@ app.get("/f/*",function(req,res){ }); }); -app.get("/.well-known/keybase.txt",function(req,res){ - res.sendFile(cmn.rootdir+"/web_files/keybase.txt"); -}); - app.get("/dr",function(req,res){ res.sendFile(cmn.rootdir+"/web_files/duckroll.html"); }); -- cgit v1.2.3-70-g09d2