Skip to content

Commit

Permalink
fix(2889): remove raw feature and allow artifacts renders SPA (#141)
Browse files Browse the repository at this point in the history
* fix(2889): remove raw feature

* fix: test
  • Loading branch information
adong authored Jul 11, 2023
1 parent b6965be commit 39da979
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 18 deletions.
8 changes: 1 addition & 7 deletions helpers/mime.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const mime = require('mime-types');

const KNOWN_FILE_EXTS_IN_TEXT_FORMAT = [
'js',
'c',
'cpp',
'cs',
Expand Down Expand Up @@ -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';
}
Expand Down
10 changes: 0 additions & 10 deletions plugins/builds.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)}"`;
}
Expand Down
2 changes: 1 addition & 1 deletion test/plugins/builds.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 39da979

Please sign in to comment.