Skip to content

Commit 18d104e

Browse files
update checks
1 parent 403e712 commit 18d104e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/lib/utils/index.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -106,25 +106,27 @@ export const getMimetype = async(file: Uint8Array | Buffer, name?: string): Prom
106106
try {
107107
type = await fromBuffer(file);
108108
} catch(e) {
109-
console.log('name: ',name)
110109
// A temporary solution for some PNG files when resized
111110
if (name == undefined){
112111
return 'image/png';
113112
}
114113
}
115-
console.log('name2: ',name)
116114
if (name && name.indexOf('.') > -1) {
117115
const mime = extensionToMime(name);
118116

119117
if (mime) {
120118
return mime;
121119
}
122120
}
123-
const excludedMimetypes = ['text/plain','image/png', 'application/octet-stream', 'application/x-ms', 'application/x-msi', 'application/zip'];
121+
const excludedMimetypes = ['text/plain', 'application/octet-stream', 'application/x-ms', 'application/x-msi', 'application/zip'];
124122

125123
if (type && excludedMimetypes.indexOf(type.mime) === -1) {
126124
return type.mime;
127125
}
126+
// if we cant find types by extensions and we have magic bytes fallback to it
127+
if (type) {
128+
return type.mime;
129+
}
128130

129131
try {
130132
if (isutf8(file)) {
@@ -137,10 +139,7 @@ export const getMimetype = async(file: Uint8Array | Buffer, name?: string): Prom
137139
// this is only fallback, omit it in coverage
138140
/* istanbul ignore next */
139141

140-
// if we cant find types by extensions and we have magic bytes fallback to it
141-
if (type) {
142-
return type.mime;
143-
}
142+
144143

145144
};
146145

0 commit comments

Comments
 (0)