From 136abb4bb3c24abdeecc578fbfa22d5b2bfb70ec Mon Sep 17 00:00:00 2001 From: Manuel Roth Date: Tue, 11 Sep 2018 14:16:47 +0200 Subject: [PATCH 1/5] Get file extension for js resources based on content-type application/javascript --- plugins/file/index.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/file/index.js b/plugins/file/index.js index 852a8536..b3d1e882 100644 --- a/plugins/file/index.js +++ b/plugins/file/index.js @@ -87,7 +87,15 @@ module.exports = { return Boom.unsupportedMediaType("Content-type not allowed"); } - const type = mimos.type(contentType); + // The mimos package doesn't store the extension for the content-type text/javascript + // because its marked as depricated by IANA. Therefore we get the mimos type based on the + // content-type application/javascript + let type; + if (contentType === "text/javascript") { + type = mimos.type("application/javascript"); + } else { + type = mimos.type(contentType); + } const extension = type.extensions[0] || ""; // buffer the contents to hash and later upload to s3 From 75fd3efaf45b236c70d08cbdf4abe90b02bb172a Mon Sep 17 00:00:00 2001 From: Manuel Roth Date: Tue, 11 Sep 2018 14:23:13 +0200 Subject: [PATCH 2/5] Fix wording in comment --- plugins/file/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/file/index.js b/plugins/file/index.js index b3d1e882..5ad07c37 100644 --- a/plugins/file/index.js +++ b/plugins/file/index.js @@ -88,8 +88,8 @@ module.exports = { } // The mimos package doesn't store the extension for the content-type text/javascript - // because its marked as depricated by IANA. Therefore we get the mimos type based on the - // content-type application/javascript + // because its marked as depricated by IANA. Therefore we get the file extension based + // on the content-type application/javascript let type; if (contentType === "text/javascript") { type = mimos.type("application/javascript"); From 1e2eb46d68536addfb1cd3f22cecd5e54d631c7c Mon Sep 17 00:00:00 2001 From: Manuel Roth Date: Wed, 12 Sep 2018 11:58:05 +0200 Subject: [PATCH 3/5] Fix typo in comment --- plugins/file/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/file/index.js b/plugins/file/index.js index 5ad07c37..30e724f7 100644 --- a/plugins/file/index.js +++ b/plugins/file/index.js @@ -88,7 +88,7 @@ module.exports = { } // The mimos package doesn't store the extension for the content-type text/javascript - // because its marked as depricated by IANA. Therefore we get the file extension based + // because its marked as deprecated by IANA. Therefore we get the file extension based // on the content-type application/javascript let type; if (contentType === "text/javascript") { From c1ab33de6b919b9429b8f6744f8ab39288e0b9bf Mon Sep 17 00:00:00 2001 From: Manuel Roth Date: Wed, 12 Sep 2018 12:03:41 +0200 Subject: [PATCH 4/5] Refactore mimos type code --- plugins/file/index.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/file/index.js b/plugins/file/index.js index 30e724f7..7fc0ad2d 100644 --- a/plugins/file/index.js +++ b/plugins/file/index.js @@ -90,11 +90,9 @@ module.exports = { // The mimos package doesn't store the extension for the content-type text/javascript // because its marked as deprecated by IANA. Therefore we get the file extension based // on the content-type application/javascript - let type; + let type = mimos.type(contentType); if (contentType === "text/javascript") { type = mimos.type("application/javascript"); - } else { - type = mimos.type(contentType); } const extension = type.extensions[0] || ""; From e26d3f9198778d33b226d3f27361912822adb6af Mon Sep 17 00:00:00 2001 From: Manuel Roth Date: Wed, 12 Sep 2018 12:04:58 +0200 Subject: [PATCH 5/5] Move comment on mimos package --- plugins/file/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/file/index.js b/plugins/file/index.js index 7fc0ad2d..db5bb00c 100644 --- a/plugins/file/index.js +++ b/plugins/file/index.js @@ -87,10 +87,10 @@ module.exports = { return Boom.unsupportedMediaType("Content-type not allowed"); } + let type = mimos.type(contentType); // The mimos package doesn't store the extension for the content-type text/javascript // because its marked as deprecated by IANA. Therefore we get the file extension based // on the content-type application/javascript - let type = mimos.type(contentType); if (contentType === "text/javascript") { type = mimos.type("application/javascript"); }