Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sirv accepts mime option to allow mime checking to be overridden & extended #39

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/sirv/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -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,
});
Expand All @@ -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(),
};

Expand Down
2 changes: 1 addition & 1 deletion packages/sirv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
},
"dependencies": {
"@polka/url": "^0.5.0",
"mime": "^2.3.1"
"mime": "^2.4.4"
}
}