修改上传组件isImageUrl判断,有些七牛返回来的后缀的大写,加以判断 (#2987)

This commit is contained in:
Ben199011 2020-04-10 23:01:36 +08:00 committed by GitHub
parent df03bf3d12
commit 0bad228027
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,10 +8,10 @@ interface File {
image: boolean; // 是否为图片 image: boolean; // 是否为图片
} }
const IMAGE_EXT = ['jpeg', 'jpg', 'gif', 'png', 'svg']; const IMAGE_EXT = ['jpeg', 'jpg', 'gif', 'png', 'svg', 'webp'];
export function isImageUrl(url: string): boolean { export function isImageUrl(url: string): boolean {
return IMAGE_EXT.some(ext => url.indexOf(`.${ext}`) !== -1); return IMAGE_EXT.some(ext => url.indexOf(`.${ext}`) !== -1 || url.indexOf(`.${ext.toLocaleUpperCase()}`) !== -1); // 有些七牛返回来的后缀的大写,加以判断
} }
export function isImageFile(item: File): boolean { export function isImageFile(item: File): boolean {