From f09805130ea992ff7ac6144a8d8ddcb1043cb8f5 Mon Sep 17 00:00:00 2001 From: Brian Takita Date: Fri, 30 Aug 2019 11:53:57 -0400 Subject: [PATCH 1/2] sirv accepts mime option to allow mime checking to be overridden & extended. Fix: https://github.com/lukeed/sirv/issues/38 --- packages/sirv/index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/sirv/index.js b/packages/sirv/index.js index caa9be0..e8c6cdd 100644 --- a/packages/sirv/index.js +++ b/packages/sirv/index.js @@ -71,6 +71,7 @@ function send(req, res, file, stats, headers={}) { module.exports = function (dir, opts={}) { dir = resolve(dir || '.'); + const mime2 = opts.mime || mime; let isNotFound = opts.onNoMatch || is404; let extensions = opts.extensions || ['html', 'htm']; @@ -85,7 +86,7 @@ module.exports = function (dir, opts={}) { if (stats.isDirectory()) continue; setHeaders(res, uri, stats); return send(req, res, file, stats, { - 'Content-Type': mime.getType(file), + 'Content-Type': mime2.getType(file), 'Last-Modified': stats.mtime.toUTCString(), 'Content-Length': stats.size, }); @@ -104,7 +105,7 @@ module.exports = function (dir, opts={}) { let headers = { 'Content-Length': stats.size, - 'Content-Type': mime.getType(name), + 'Content-Type': mime2.getType(name), 'Last-Modified': stats.mtime.toUTCString(), }; From 69cef5d9711b914bd972da6b3fdad855a3cf6d1d Mon Sep 17 00:00:00 2001 From: Brian Takita Date: Fri, 30 Aug 2019 12:25:05 -0400 Subject: [PATCH 2/2] updated mime version --- packages/sirv/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sirv/package.json b/packages/sirv/package.json index 7c25891..8cab711 100644 --- a/packages/sirv/package.json +++ b/packages/sirv/package.json @@ -17,6 +17,6 @@ }, "dependencies": { "@polka/url": "^0.5.0", - "mime": "^2.3.1" + "mime": "^2.4.4" } }