unpkg/server/utils/getFileContentType.js

14 lines
351 B
JavaScript
Raw Normal View History

2017-11-25 21:25:01 +00:00
const mime = require("mime")
2017-08-18 19:57:42 +00:00
mime.define({
2017-11-25 21:25:01 +00:00
"text/plain": ["authors", "changes", "license", "makefile", "patents", "readme", "ts", "flow"]
2017-08-18 19:57:42 +00:00
})
const TextFiles = /\/?(\.[a-z]*rc|\.git[a-z]*|\.[a-z]*ignore)$/i
function getFileContentType(file) {
2017-11-25 21:25:01 +00:00
return TextFiles.test(file) ? "text/plain" : mime.lookup(file)
2017-08-18 19:57:42 +00:00
}
module.exports = getFileContentType