Files
photon-tbw/src/lib/ui/image.ts
T
2023-07-04 20:18:25 -07:00

12 lines
302 B
TypeScript

export const isImage = (url: string | undefined) => {
if (!url) return false
return /\.(jpeg|jpg|gif|png|svg|bmp|webp)$/i.test(new URL(url).pathname)
}
export const isVideo = (url: string | undefined) => {
if (!url) return false
return new URL(url).pathname.toLowerCase().endsWith('.mp4')
}