summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xwebserver.js42
1 files 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<module_list.length;i++){
}
-
-app.get("/",function(req,res){
- res.send(
- String(fs.readFileSync(cmn.serverdir+"/index.html"))
- .replace(/<!--<<PULSE-KEYS>>-->/,whatpulse["keys"])
- .replace(/<!--<<PULSE-CLICKS>>-->/,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(/<!--<<PULSE-KEYS>>-->/,whatpulse["keys"])
+ .replace(/<!--<<PULSE-CLICKS>>-->/,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");
});