Skip to content

Commit 27c989c

Browse files
JCapulmartinRenou
authored andcommitted
Refactor base64 conditions in single if
1 parent 0ff7354 commit 27c989c

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

src/drive.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -378,22 +378,17 @@ export class FileSystemDrive implements Contents.IDrive {
378378
// We assume here image, audio, video, zip and pdf mimetypes are all and only binary files we'll encounter
379379
if (
380380
file.type &&
381-
file.type.split('/') &&
382-
['image', 'audio', 'video'].includes(file.type.split('/')[0])
383-
) {
384-
format = 'base64';
385-
} else {
386-
if (
381+
((file.type.split('/') &&
382+
['image', 'audio', 'video'].includes(file.type.split('/')[0])) ||
387383
[
388384
'application/zip',
389385
'application/pdf',
390386
'application/octet-stream'
391-
].includes(file.type)
392-
) {
393-
format = 'base64';
394-
} else {
395-
format = 'text';
396-
}
387+
].includes(file.type))
388+
) {
389+
format = 'base64';
390+
} else {
391+
format = 'text';
397392
}
398393

399394
if (content) {

0 commit comments

Comments
 (0)