From 2c944eba34eda4cc3543e5a7b5f866db44ac974b Mon Sep 17 00:00:00 2001 From: John McLear Date: Mon, 1 Jun 2020 19:37:54 +0100 Subject: [PATCH] minification: use mime lookup for mime types (#3979) --- src/node/utils/Minify.js | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/src/node/utils/Minify.js b/src/node/utils/Minify.js index 2a9f2a5e7..ef1b89a07 100644 --- a/src/node/utils/Minify.js +++ b/src/node/utils/Minify.js @@ -30,6 +30,7 @@ var path = require('path'); var plugins = require("ep_etherpad-lite/static/js/pluginfw/plugins"); var RequireKernel = require('etherpad-require-kernel'); var urlutil = require('url'); +var mime = require('mime-types') var ROOT_DIR = path.normalize(__dirname + "/../../static/"); var TAR_PATH = path.join(__dirname, 'tar.json'); @@ -177,26 +178,7 @@ function minify(req, res) } } - // What content type should this be? - // TODO: This should use a MIME module. - var contentType; - if (filename.match(/\.js$/)) { - contentType = "text/javascript"; - } else if (filename.match(/\.css$/)) { - contentType = "text/css"; - } else if (filename.match(/\.html$/)) { - contentType = "text/html"; - } else if (filename.match(/\.txt$/)) { - contentType = "text/plain"; - } else if (filename.match(/\.png$/)) { - contentType = "image/png"; - } else if (filename.match(/\.gif$/)) { - contentType = "image/gif"; - } else if (filename.match(/\.ico$/)) { - contentType = "image/x-icon"; - } else { - contentType = "application/octet-stream"; - } + var contentType = mime.lookup(filename); statFile(filename, function (error, date, exists) { if (date) {