Merge pull request #5783 from madarche/fix-route-touchicon

Fix /apple-touch-icon not sending uploaded file
This commit is contained in:
Barış Soner Uşaklı
2017-06-28 12:03:38 -04:00
committed by GitHub
2 changed files with 17 additions and 3 deletions

View File

@@ -83,7 +83,13 @@ middleware.routeTouchIcon = function (req, res) {
if (meta.config['brand:touchIcon'] && validator.isURL(meta.config['brand:touchIcon'])) {
return res.redirect(meta.config['brand:touchIcon']);
}
return res.sendFile(path.join(__dirname, '../../public', meta.config['brand:touchIcon'] || '/logo.png'), {
var iconPath = '../../public';
if (meta.config['brand:touchIcon']) {
iconPath += meta.config['brand:touchIcon'].replace(/assets\/uploads/, 'uploads');
} else {
iconPath += '/logo.png';
}
return res.sendFile(path.join(__dirname, iconPath), {
maxAge: req.app.enabled('cache') ? 5184000000 : 0,
});
};