unpkg/server/utils/getFileContentType.js

14 lines
351 B
JavaScript

const mime = require("mime")
mime.define({
"text/plain": ["authors", "changes", "license", "makefile", "patents", "readme", "ts", "flow"]
})
const TextFiles = /\/?(\.[a-z]*rc|\.git[a-z]*|\.[a-z]*ignore)$/i
function getFileContentType(file) {
return TextFiles.test(file) ? "text/plain" : mime.lookup(file)
}
module.exports = getFileContentType