@uppy/utils
Version:
Shared utility functions for Uppy Core and plugins maintained by the Uppy team.
27 lines • 706 B
JavaScript
const mimeToExtensions = {
__proto__: null,
'audio/mp3': 'mp3',
'audio/mp4': 'mp4',
'audio/ogg': 'ogg',
'audio/webm': 'webm',
'image/gif': 'gif',
'image/heic': 'heic',
'image/heif': 'heif',
'image/jpeg': 'jpg',
'image/webp': 'webp',
'image/png': 'png',
'image/svg+xml': 'svg',
'video/mp4': 'mp4',
'video/ogg': 'ogv',
'video/quicktime': 'mov',
'video/webm': 'webm',
'video/x-matroska': 'mkv',
'video/x-msvideo': 'avi'
};
export default function getFileTypeExtension(mimeType) {
// Remove the ; bit in 'video/x-matroska;codecs=avc1'
// eslint-disable-next-line no-param-reassign
;
[mimeType] = mimeType.split(';', 1);
return mimeToExtensions[mimeType] || null;
}