From 32d7fc55d21f50d67f4323d06afeb04dd9a6c60f Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 28 Dec 2016 17:11:06 +0100 Subject: [PATCH] make it easier to add pages at the document root --- config.js.dist | 10 ++++++++++ server.js | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/config.js.dist b/config.js.dist index 76518baea..b015b55be 100644 --- a/config.js.dist +++ b/config.js.dist @@ -66,6 +66,16 @@ module.exports = { */ verbose: false, + /* Main pages + * add exceptions to the router so that we can access /privacy.html + * and other odd pages + */ + mainPages: [ + 'index', + 'privacy', + 'terms', + 'about', + ], /* You have the option of specifying an alternative storage adaptor. diff --git a/server.js b/server.js index f24117bd1..61e58a482 100644 --- a/server.js +++ b/server.js @@ -45,7 +45,10 @@ Fs.exists(__dirname + "/customize", function (e) { // FIXME I think this is a regression caused by a recent PR // correct this hack without breaking the contributor's intended behaviour. -app.get(/\/(privacy|index|terms)\.html/, Express.static(__dirname + '/customize.dist')); + +var mainPages = config.mainPages || ['index', 'privacy', 'terms', 'about']; +var mainPagePattern = new RegExp('^\/(' + mainPages.join('|') + ').html$'); +app.get(mainPagePattern, Express.static(__dirname + '/customize.dist')); app.use("/customize", Express.static(__dirname + '/customize')); app.use("/customize", Express.static(__dirname + '/customize.dist'));