From f22937f3d158e5fcb194ec201b1a72ff2d84776d Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Tue, 17 Feb 2015 22:49:24 -0500 Subject: [PATCH] Use content-type to parse Content-Type headers --- History.md | 1 + lib/utils.js | 19 ++++++++++++++----- package.json | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/History.md b/History.md index 349b925f..83b8a556 100644 --- a/History.md +++ b/History.md @@ -1,6 +1,7 @@ 3.x === + * Use `content-type` to parse `Content-Type` headers * deps: connect@2.29.0 - Use `content-type` to parse `Content-Type` headers - deps: body-parser@~1.12.0 diff --git a/lib/utils.js b/lib/utils.js index b9ff7bbd..889b62d5 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,12 +1,19 @@ +/*! + * express + * Copyright(c) 2009-2013 TJ Holowaychuk + * Copyright(c) 2014-2015 Douglas Christopher Wilson + * MIT Licensed + */ /** * Module dependencies. + * @api private */ +var contentType = require('content-type'); var etag = require('etag'); var mime = require('connect').mime; var proxyaddr = require('proxy-addr'); -var typer = require('media-typer'); /** * toString ref. @@ -393,15 +400,17 @@ exports.compileTrust = function(val) { * @api private */ -exports.setCharset = function(type, charset){ - if (!type || !charset) return type; +exports.setCharset = function setCharset(type, charset) { + if (!type || !charset) { + return type; + } // parse type - var parsed = typer.parse(type); + var parsed = contentType.parse(type); // set charset parsed.parameters.charset = charset; // format type - return typer.format(parsed); + return contentType.format(parsed); }; diff --git a/package.json b/package.json index 1e2a7ca5..e2dca4d9 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "basic-auth": "1.0.0", "connect": "2.29.0", "content-disposition": "0.5.0", + "content-type": "~1.0.1", "commander": "2.6.0", "cookie-signature": "1.0.6", "debug": "~2.1.1", @@ -36,7 +37,6 @@ "escape-html": "1.0.1", "etag": "~1.5.1", "fresh": "0.2.4", - "media-typer": "0.3.0", "methods": "~1.1.1", "mkdirp": "0.5.0", "parseurl": "~1.3.0",