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

mime => mime-types #33

Merged
merged 1 commit into from
Oct 19, 2016
Merged
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
12 changes: 4 additions & 8 deletions bin/list
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import args from 'args'
import {compile} from 'handlebars'
import {isBinarySync as isBinary} from 'istextorbinary'
import filesize from 'filesize'
import mime from 'mime'
import mime from 'mime-types'
import compress from 'micro-compress'
import fs from 'fs-promise'

Expand Down Expand Up @@ -184,7 +184,7 @@ const handler = async (req, res) => {
return send(res, 404, 'Not found')
}

res.setHeader('Content-Type', mime.lookup(indexPath) + '; charset=utf-8')
res.setHeader('Content-Type', mime.contentType(path.extname(indexPath)))

if (!fs.existsSync(indexPath)) {
// Try to render the current directory's content
Expand Down Expand Up @@ -259,13 +259,9 @@ const handler = async (req, res) => {
res.end(body, 'binary')
} else {
const decoder = new StringDecoder('utf8')
let contentType = mime.lookup(related)
const contentType = mime.contentType(path.extname(related)) || mime.contentType('text')

if (!path.parse(related).ext) {
contentType = 'text/plain'
}

res.setHeader('Content-Type', contentType + '; charset=utf-8')
res.setHeader('Content-Type', contentType)
send(res, statusCode, decoder.write(body))
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@
"istextorbinary": "2.1.0",
"micro": "6.1.0",
"micro-compress": "1.0.0",
"mime": "1.3.4"
"mime-types": "^2.1.12"
}
}