Skip to content

Commit 61741c3

Browse files
committed
fix(mimetype): Fixed getMimetype response
1 parent 3cf7ebc commit 61741c3

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/lib/utils/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,17 @@ export const getMimetype = async(file: Uint8Array | Buffer, name?: string): Prom
105105
let type;
106106

107107
try {
108-
type = await fromBuffer(file);
108+
type = await fromBuffer(file);
109109
} catch(e) {
110110
console.warn("An exception occurred while processing the buffer:", e.message);
111111
}
112112

113+
const excludedMimetypes = ['text/plain', 'application/octet-stream', 'application/x-ms', 'application/x-msi', 'application/zip'];
114+
115+
if (type && excludedMimetypes.indexOf(type.mime) === -1) {
116+
return type.mime;
117+
}
118+
113119
if (name && name.indexOf('.') > -1) {
114120
const mime = extensionToMime(name);
115121

@@ -118,12 +124,6 @@ export const getMimetype = async(file: Uint8Array | Buffer, name?: string): Prom
118124
}
119125
}
120126

121-
const excludedMimetypes = ['text/plain', 'application/octet-stream', 'application/x-ms', 'application/x-msi', 'application/zip'];
122-
123-
if (type && excludedMimetypes.indexOf(type.mime) === -1) {
124-
return type.mime;
125-
}
126-
127127
try {
128128
if (isutf8(file)) {
129129
return 'text/plain';

webpack.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ const banner = fs.readFileSync('./LICENSE', 'utf8').replace('{year}', new Date()
1010
const config = {
1111
mode: 'production',
1212
node: {
13-
Buffer: false,
13+
Buffer: true,
14+
buffer: true,
1415
fs: 'empty',
1516
},
1617
watchOptions: {

0 commit comments

Comments
 (0)