From 5560f729124f022ffed00085aafea43dded7fb03 Mon Sep 17 00:00:00 2001 From: Jordan Date: Fri, 7 Dec 2018 15:22:12 +0800 Subject: [PATCH] chore: use the ability of `content-type` lib directly (#1276) --- lib/request.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/request.js b/lib/request.js index 0b0b262..e075cbe 100644 --- a/lib/request.js +++ b/lib/request.js @@ -367,16 +367,12 @@ module.exports = { */ get charset() { - let type = this.get('Content-Type'); - if (!type) return ''; - try { - type = contentType.parse(type); + const { parameters } = contentType.parse(this.req); + return parameters.charset || ''; } catch (e) { return ''; } - - return type.parameters.charset || ''; }, /**