From e472a18010b0b067331740d7934333924f4b8dbb Mon Sep 17 00:00:00 2001 From: Jonathan Ong Date: Sat, 19 Apr 2014 07:45:57 -0700 Subject: [PATCH] refactor: use mime-extended --- History.md | 5 +++++ lib/response.js | 13 ++----------- package.json | 1 + 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/History.md b/History.md index b33b9e9..e341680 100644 --- a/History.md +++ b/History.md @@ -1,4 +1,9 @@ +HEAD / +================== + + * refactor mime with mime-extended + 0.5.5 / 2014-04-14 ================== diff --git a/lib/response.js b/lib/response.js index 45c9626..4e399c6 100644 --- a/lib/response.js +++ b/lib/response.js @@ -11,7 +11,7 @@ var status = require('statuses'); var destroy = require('dethroy'); var http = require('http'); var path = require('path'); -var mime = require('mime'); +var mime = require('mime-extended'); var basename = path.basename; var extname = path.extname; @@ -265,16 +265,7 @@ module.exports = { */ set type(type) { - // mime - if (!~type.indexOf('/')) type = mime.lookup(type); - - // charset - if (!~type.indexOf('charset')) { - var cs = mime.charsets.lookup(type); - if (cs) type += '; charset=' + cs.toLowerCase(); - } - - this.set('Content-Type', type); + this.set('Content-Type', mime.contentType(type)); }, /** diff --git a/package.json b/package.json index 7a65507..50ed0b4 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "co": "~3.0.2", "debug": "*", "mime": "~1.2.11", + "mime-extended": "^1.0.0", "fresh": "~0.2.1", "koa-compose": "~2.2.0", "cookies": "~0.4.0",