parse req.type by media-typer
This commit is contained in:
parent
690604b6d2
commit
5b18f8bab0
3 changed files with 4 additions and 4 deletions
|
@ -7,6 +7,7 @@ var qs = require('querystring');
|
|||
var typeis = require('type-is');
|
||||
var fresh = require('fresh');
|
||||
var url = require('url');
|
||||
var typer = require('media-typer');
|
||||
var stringify = url.format;
|
||||
var parse = url.parse;
|
||||
|
||||
|
@ -272,12 +273,10 @@ module.exports = {
|
|||
*/
|
||||
|
||||
get charset() {
|
||||
// TODO: lame, we could have a generic param parsing lib
|
||||
var type = this.get('Content-Type');
|
||||
if (!type) return;
|
||||
|
||||
var m = type.match(/charset *= *(\S+)/);
|
||||
if (m) return m[1];
|
||||
return typer.parse(type).parameters.charset;
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
"accepts": "~1.0.0",
|
||||
"type-is": "~1.3.1",
|
||||
"mime-types": "~1.0.0",
|
||||
"media-typer": "~0.2.0",
|
||||
"finished": "~1.2.0",
|
||||
"co": "~3.0.2",
|
||||
"debug": "*",
|
||||
|
|
Loading…
Reference in a new issue