Skip to content

Commit 5560f72

Browse files
mingmingwondead-horse
authored andcommitted
chore: use the ability of content-type lib directly (#1276)
1 parent 281a04e commit 5560f72

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/request.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -367,16 +367,12 @@ module.exports = {
367367
*/
368368

369369
get charset() {
370-
let type = this.get('Content-Type');
371-
if (!type) return '';
372-
373370
try {
374-
type = contentType.parse(type);
371+
const { parameters } = contentType.parse(this.req);
372+
return parameters.charset || '';
375373
} catch (e) {
376374
return '';
377375
}
378-
379-
return type.parameters.charset || '';
380376
},
381377

382378
/**

0 commit comments

Comments
 (0)