@limetech/lime-elements
Version:
72 lines (71 loc) • 1.43 kB
JavaScript
/**
*
* @param fileName
* @param url
*/
export function detectExtension(fileName, url) {
const pathLike = fileName || url;
if (!pathLike) {
return 'unknown';
}
const extension = pathLike.split('.').pop().toLowerCase();
const extensionsToTypes = {
pdf: 'pdf',
jpg: 'image',
jpeg: 'image',
heic: 'image',
bmp: 'image',
png: 'image',
gif: 'image',
svg: 'image',
svgz: 'image',
ep: 'image',
eps: 'image',
avi: 'video',
flv: 'video',
h264: 'video',
mov: 'video',
mp4: 'video',
mwv: 'video',
mkv: 'video',
mp3: 'audio',
wav: 'audio',
wma: 'audio',
ogg: 'audio',
txt: 'text',
json: 'text',
html: 'text',
xml: 'text',
// Word
doc: 'office',
docx: 'office',
odt: 'office',
dot: 'office',
dotx: 'office',
docm: 'office',
dotm: 'office',
// Presentation
pot: 'office',
ppt: 'office',
pptx: 'office',
odp: 'office',
potx: 'office',
potm: 'office',
pps: 'office',
ppsx: 'office',
ppsm: 'office',
pptm: 'office',
ppam: 'office',
pages: 'office',
// Spreadsheet
xls: 'office',
xlsx: 'office',
xlsm: 'office',
xlsb: 'office',
ods: 'office',
csv: 'office',
numbers: 'office', // not supported (Apple)
};
return extensionsToTypes[extension] || 'unknown';
}
//# sourceMappingURL=extension-mapping.js.map