From d1481041c27b24ed2357cd829ef3da85f58f3ff3 Mon Sep 17 00:00:00 2001 From: muxator Date: Thu, 23 Aug 2018 23:39:38 +0200 Subject: [PATCH] specialpages: replace relative paths for sendfile() with absolute ones This file uses it for robots.txt and favicon.ico. This makes use of the new stable settings.root introduced with #3466, and will be modified when introducing support for custom skins. --- src/node/hooks/express/specialpages.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/node/hooks/express/specialpages.js b/src/node/hooks/express/specialpages.js index 2840f82ca..ec1496499 100644 --- a/src/node/hooks/express/specialpages.js +++ b/src/node/hooks/express/specialpages.js @@ -26,13 +26,13 @@ exports.expressCreateServer = function (hook_name, args, cb) { //serve robots.txt args.app.get('/robots.txt', function(req, res) { - var filePath = path.normalize(__dirname + "/../../../static/custom/robots.txt"); + var filePath = path.join(settings.root, "src", "static", "custom", "robots.txt"); res.sendFile(filePath, function(err) { //there is no custom favicon, send the default robots.txt which dissallows all if(err) { - filePath = path.normalize(__dirname + "/../../../static/robots.txt"); + filePath = path.join(settings.root, "src", "static", "robots.txt"); res.sendFile(filePath); } }); @@ -79,13 +79,14 @@ exports.expressCreateServer = function (hook_name, args, cb) { //serve favicon.ico from all path levels except as a pad name args.app.get( /\/favicon.ico$/, function(req, res) { - var filePath = path.normalize(__dirname + "/../../../static/custom/favicon.ico"); + var filePath = path.join(settings.root, "src", "static", "custom", "favicon.ico"); + res.sendFile(filePath, function(err) { //there is no custom favicon, send the default favicon if(err) { - filePath = path.normalize(__dirname + "/../../../static/favicon.ico"); + filePath = path.join(settings.root, "src", "static", "favicon.ico"); res.sendFile(filePath); } });