chore: use the ability of content-type lib directly (#1276)

This commit is contained in:
Jordan 2018-12-07 15:22:12 +08:00 committed by Yiyu He
parent 281a04e8e1
commit 5560f72912

View file

@ -367,16 +367,12 @@ module.exports = {
*/ */
get charset() { get charset() {
let type = this.get('Content-Type');
if (!type) return '';
try { try {
type = contentType.parse(type); const { parameters } = contentType.parse(this.req);
return parameters.charset || '';
} catch (e) { } catch (e) {
return ''; return '';
} }
return type.parameters.charset || '';
}, },
/** /**