From 39da9791de3603ac7e983d6ac28b10786d0b2936 Mon Sep 17 00:00:00 2001 From: Alan Date: Tue, 11 Jul 2023 10:16:45 -0700 Subject: [PATCH] fix(2889): remove raw feature and allow artifacts renders SPA (#141) * fix(2889): remove raw feature * fix: test --- helpers/mime.js | 8 +------- plugins/builds.js | 10 ---------- test/plugins/builds.test.js | 2 +- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/helpers/mime.js b/helpers/mime.js index 0a61fd5..1218b60 100644 --- a/helpers/mime.js +++ b/helpers/mime.js @@ -3,7 +3,6 @@ const mime = require('mime-types'); const KNOWN_FILE_EXTS_IN_TEXT_FORMAT = [ - 'js', 'c', 'cpp', 'cs', @@ -34,14 +33,9 @@ const KNOWN_FILE_EXTS_IN_TEXT_FORMAT = [ * @method getMimeFromFileName * @param {String} fileExtension File extension (e.g. css, txt, html) * @param {String} fileName File name (e.g. dockerfile, main) - * @param {Boolean} raw raw data type (e.g. application/javascript instead of text/javascript) * @return {String} MIME Type eg. text/html, text/plain */ -function getMimeFromFileName(fileExtension, fileName = '', raw = false) { - if (raw === true) { - return mime.lookup(fileExtension) || ''; - } - +function getMimeFromFileName(fileExtension, fileName = '') { if (fileName.toLowerCase().endsWith('file')) { return 'text/plain'; } diff --git a/plugins/builds.js b/plugins/builds.js index 684cda0..e735645 100644 --- a/plugins/builds.js +++ b/plugins/builds.js @@ -101,16 +101,6 @@ exports.plugin = { response.headers['content-type'] = mime; - if (!displayableMimes.includes(mime)) { - response.headers['content-disposition'] = `inline; filename="${encodeURI(fileName)}"`; - } - } else { - const fileExt = fileName.split('.').pop(); - const raw = true; - const mime = getMimeFromFileName(fileExt, fileName, raw); - - response.headers['content-type'] = mime; - if (!displayableMimes.includes(mime)) { response.headers['content-disposition'] = `inline; filename="${encodeURI(fileName)}"`; } diff --git a/test/plugins/builds.test.js b/test/plugins/builds.test.js index d5eae55..4074114 100644 --- a/test/plugins/builds.test.js +++ b/test/plugins/builds.test.js @@ -290,7 +290,7 @@ describe('builds plugin test', () => { it('saves an artifact', async () => { options.url = `/builds/${mockBuildID}/foo`; - options.headers['content-type'] = 'application/x-ndjson'; + options.headers['content-type'] = 'application/octet-stream'; const putResponse = await server.inject(options); assert.equal(putResponse.statusCode, 202);