mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-11 19:42:54 +08:00
fix: upload preview can't show image when the image file use uppercase extension
1.fix: upload preview can't show image when the image file use uppercase extension. 2.improve: remove unnecessary escape character.
This commit is contained in:
parent
a5ff8e5de0
commit
450a497412
@ -19,13 +19,13 @@ const extname = (url: string) => {
|
|||||||
}
|
}
|
||||||
const temp = url.split('/');
|
const temp = url.split('/');
|
||||||
const filename = temp[temp.length - 1];
|
const filename = temp[temp.length - 1];
|
||||||
const filenameWithoutSuffix = filename.split(/\#|\?/)[0];
|
const filenameWithoutSuffix = filename.split(/#|\?/)[0];
|
||||||
return (/\.[^./\\]*$/.exec(filenameWithoutSuffix) || [''])[0];
|
return (/\.[^./\\]*$/.exec(filenameWithoutSuffix) || [''])[0];
|
||||||
};
|
};
|
||||||
|
|
||||||
const isImageUrl = (url: string): boolean => {
|
const isImageUrl = (url: string): boolean => {
|
||||||
const extension = extname(url);
|
const extension = extname(url);
|
||||||
if (/^data:image\//.test(url) || /(webp|svg|png|gif|jpg|jpeg|bmp)$/.test(extension)) {
|
if (/^data:image\//.test(url) || /(webp|svg|png|gif|jpg|jpeg|bmp)$/i.test(extension)) {
|
||||||
return true;
|
return true;
|
||||||
} else if (/^data:/.test(url)) { // other file types of base64
|
} else if (/^data:/.test(url)) { // other file types of base64
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user