31 lines
466 B
TypeScript
31 lines
466 B
TypeScript
const imageExtList = [
|
|
"jpeg",
|
|
"jpg",
|
|
"png",
|
|
"gif",
|
|
"svg",
|
|
"tiff",
|
|
"bmp"
|
|
]
|
|
|
|
const imageChecker = (filename: string) => {
|
|
|
|
if (filename.length < 1 || !filename.includes(".")) {
|
|
|
|
return false;
|
|
}
|
|
|
|
const extSplit = filename.split(".");
|
|
|
|
if (extSplit.length <= 1) {
|
|
|
|
return false;
|
|
}
|
|
|
|
const ext = extSplit[extSplit.length - 1];
|
|
|
|
return imageExtList.includes(ext.toLowerCase());
|
|
|
|
}
|
|
|
|
export default imageChecker; |