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

Fix /apple-touch-icon not sending uploaded file
v1.18.x
Barış Soner Uşaklı 8 years ago committed by GitHub
commit fd55e4ccdf

@ -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,
});
};

@ -4,6 +4,7 @@ var async = require('async');
var assert = require('assert');
var nconf = require('nconf');
var path = require('path');
var request = require('request');
var db = require('./mocks/databasemock');
var categories = require('../src/categories');
@ -247,13 +248,20 @@ describe('Upload Controllers', function () {
});
it('should upload touch icon', function (done) {
var touchiconAssetPath = '/assets/uploads/system/touchicon-orig.png';
helpers.uploadFile(nconf.get('url') + '/api/admin/uploadTouchIcon', path.join(__dirname, '../test/files/test.png'), {}, jar, csrf_token, function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(Array.isArray(body));
assert.equal(body[0].url, '/assets/uploads/system/touchicon-orig.png');
assert.equal(body[0].url, touchiconAssetPath);
meta.config['brand:touchIcon'] = touchiconAssetPath;
request(nconf.get('url') + '/apple-touch-icon', function (err, res, body) {
assert.ifError(err);
assert.equal(res.statusCode, 200);
assert(body);
done();
});
});
});
});
});

Loading…
Cancel
Save