2022-08-03 06:31:35 +00:00
|
|
|
/* eslint-disable eslint-comments/disable-enable-pair */
|
|
|
|
/* eslint-disable @typescript-eslint/no-unnecessary-condition */
|
2023-01-24 06:48:50 +00:00
|
|
|
export type AssetType = 'image' | 'audio' | 'video' | 'html' | 'unknown'
|
2022-08-03 06:31:35 +00:00
|
|
|
|
|
|
|
export const getAssetType = (assetFileName: string): AssetType => {
|
2023-06-03 04:01:57 +00:00
|
|
|
const assetType = assetFileName?.toLowerCase().split('.').pop() || 'unknown'
|
2022-09-27 08:31:33 +00:00
|
|
|
if (assetType === 'png' || assetType === 'jpg' || assetType === 'jpeg' || assetType === 'svg' || assetType === 'gif')
|
|
|
|
return 'image'
|
2022-08-03 06:31:35 +00:00
|
|
|
if (assetType === 'mp3' || assetType === 'wav') return 'audio'
|
|
|
|
if (assetType === 'mp4') return 'video'
|
2023-01-24 06:48:50 +00:00
|
|
|
if (assetType === 'html') return 'html'
|
2022-08-03 06:31:35 +00:00
|
|
|
return 'unknown'
|
|
|
|
}
|