allow manifest.json in theme root (#6986)

closes #6769
This commit is contained in:
Lukas Strassel 2016-06-29 22:44:01 +02:00 committed by Austin Burdine
parent 72f7b0bc6c
commit 03137ff5cd
2 changed files with 28 additions and 1 deletions

View File

@ -10,6 +10,12 @@ function isBlackListedFileType(file) {
return _.includes(blackListedFileTypes, ext);
}
function isWhiteListedFile(file) {
var whiteListedFiles = ['manifest.json'],
base = path.basename(file);
return _.includes(whiteListedFiles, base);
}
function forwardToExpressStatic(req, res, next) {
if (!req.app.get('activeTheme')) {
next();
@ -23,7 +29,7 @@ function forwardToExpressStatic(req, res, next) {
function staticTheme() {
return function blackListStatic(req, res, next) {
if (isBlackListedFileType(req.path)) {
if (!isWhiteListedFile(req.path) && isBlackListedFileType(req.path)) {
return next();
}
return forwardToExpressStatic(req, res, next);

View File

@ -81,4 +81,25 @@ describe('staticTheme', function () {
done();
});
});
it('should not call next if file is on whitelist', function (done) {
var req = {
path: 'manifest.json',
app: {
get: function () { return 'casper'; }
}
},
activeThemeStub,
sandbox = sinon.sandbox.create();
activeThemeStub = sandbox.spy(req.app, 'get');
staticTheme(null)(req, null, function (reqArg, res, next2) {
/*jshint unused:false */
sandbox.restore();
next.called.should.be.false();
activeThemeStub.called.should.be.true();
done();
});
});
});