Skip to content

Commit f22937f

Browse files
committed
Use content-type to parse Content-Type headers
1 parent 69a4869 commit f22937f

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

History.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
3.x
22
===
33

4+
* Use `content-type` to parse `Content-Type` headers
45
56
- Use `content-type` to parse `Content-Type` headers
67
- deps: body-parser@~1.12.0

lib/utils.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1+
/*!
2+
* express
3+
* Copyright(c) 2009-2013 TJ Holowaychuk
4+
* Copyright(c) 2014-2015 Douglas Christopher Wilson
5+
* MIT Licensed
6+
*/
17

28
/**
39
* Module dependencies.
10+
* @api private
411
*/
512

13+
var contentType = require('content-type');
614
var etag = require('etag');
715
var mime = require('connect').mime;
816
var proxyaddr = require('proxy-addr');
9-
var typer = require('media-typer');
1017

1118
/**
1219
* toString ref.
@@ -393,15 +400,17 @@ exports.compileTrust = function(val) {
393400
* @api private
394401
*/
395402

396-
exports.setCharset = function(type, charset){
397-
if (!type || !charset) return type;
403+
exports.setCharset = function setCharset(type, charset) {
404+
if (!type || !charset) {
405+
return type;
406+
}
398407

399408
// parse type
400-
var parsed = typer.parse(type);
409+
var parsed = contentType.parse(type);
401410

402411
// set charset
403412
parsed.parameters.charset = charset;
404413

405414
// format type
406-
return typer.format(parsed);
415+
return contentType.format(parsed);
407416
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
"basic-auth": "1.0.0",
3030
"connect": "2.29.0",
3131
"content-disposition": "0.5.0",
32+
"content-type": "~1.0.1",
3233
"commander": "2.6.0",
3334
"cookie-signature": "1.0.6",
3435
"debug": "~2.1.1",
3536
"depd": "~1.0.0",
3637
"escape-html": "1.0.1",
3738
"etag": "~1.5.1",
3839
"fresh": "0.2.4",
39-
"media-typer": "0.3.0",
4040
"methods": "~1.1.1",
4141
"mkdirp": "0.5.0",
4242
"parseurl": "~1.3.0",

0 commit comments

Comments
 (0)