util-helpers
Version:
44 lines (41 loc) • 1.56 kB
JavaScript
import getExtname from './getExtname.js';
import { nativeUndefined } from './utils/native.js';
var mimeTypes = [
['text/plain', ['txt']],
['text/css', ['css']],
['text/html', ['htm', 'html']],
['text/javascript', ['js', 'mjs']],
['text/csv', ['csv']],
['text/markdown', ['md', 'markdown']],
['image/gif', ['gif']],
['image/jpeg', ['jpg', 'jpeg', 'jfif', 'pjpeg', 'pjp']],
['image/png', ['png']],
['image/svg+xml', ['svg']],
['image/webp', ['webp']],
['image/apng', ['apng']],
['image/avif', ['avif']],
['image/bmp', ['bmp']],
['image/x-icon', ['ico', 'cur']],
['image/tiff', ['tif', 'tiff']],
['application/xml', ['xml']],
['application/zip', ['zip']],
['application/pdf', ['pdf']],
['application/json', ['json']],
['application/yaml', ['yaml', 'yml']],
['application/vnd.openxmlformats-officedocument.wordprocessingml.document', ['doc', 'docx']],
['application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', ['xls', 'xlsx']],
['audio/mp3', ['mp3']],
['audio/wav', ['wav']],
['audio/aac', ['aac']],
['audio/flac', ['flac']],
['video/mp4', ['mp4']],
['video/ogg', ['ogg']],
['video/webm', ['webm']],
['video/quicktime', ['mov']]
];
function getMimeType(fileName) {
var _a;
var ext = getExtname(fileName).slice(1).toLowerCase();
return ext ? (_a = mimeTypes.find(function (item) { return item[1].includes(ext); })) === null || _a === void 0 ? void 0 : _a[0] : nativeUndefined;
}
export { getMimeType as default };