diff --git a/node/hooks/express/static.js b/node/hooks/express/static.js index 99f6eeff7..937fb26ec 100644 --- a/node/hooks/express/static.js +++ b/node/hooks/express/static.js @@ -1,5 +1,6 @@ var path = require('path'); var minify = require('../../utils/Minify'); +var plugins = require("../../pluginfw/plugins"); exports.expressCreateServer = function (hook_name, args, cb) { //serve static files @@ -8,8 +9,19 @@ exports.expressCreateServer = function (hook_name, args, cb) { res.write(minify.requireDefinition()); res.end(); }); - args.app.get('/static/*', function(req, res) - { + + args.app.get('/static/plugins/*', function(req, res) { + var url = req.url.replace(/\.\./g, '').split("?")[0]; + url = url.split("/"); + url.splice(0, 3); + var plugin_name = url.splice(0, 1)[0]; + url = url.join("/"); + + var filePath = path.normalize(path.join(plugins.plugins[plugin_name].package.path, "static", url)); + res.sendfile(filePath, { maxAge: exports.maxAge }); + }); + + args.app.get('/static/*', function(req, res) { var filePath = path.normalize(__dirname + "/../../.." + req.url.replace(/\.\./g, '').split("?")[0]); res.sendfile(filePath, { maxAge: exports.maxAge });