Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/pro-layout/src/utils/isImg/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// source by https://github.com/ant-design/pro-components/blob/master/packages/utils/src/isImg/index.ts

const imagePattern = 'png|jpg|jpeg|svg|webp|gif|bmp';
const suffixPattern = new RegExp(`\\w.(${imagePattern})$`, 'i');
const base64Pattern = new RegExp(`^data:image\\/(${imagePattern})`, 'i');

/** 判断是否是图片链接 */
function isImg(path: string): boolean {
return /\w.(png|jpg|jpeg|svg|webp|gif|bmp)$/i.test(path);
return suffixPattern.test(path) || base64Pattern.test(path);
}

export default isImg;
6 changes: 5 additions & 1 deletion packages/utils/src/isImg/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
// source by https://github.com/ant-design/pro-components/blob/master/packages/utils/src/isImg/index.ts

const imagePattern = 'png|jpg|jpeg|svg|webp|gif|bmp';
const suffixPattern = new RegExp(`\\w.(${imagePattern})$`, 'i');
const base64Pattern = new RegExp(`^data:image\\/(${imagePattern})`, 'i');

/** 判断是否是图片链接 */
function isImg(path: string): boolean {
return /\w.(png|jpg|jpeg|svg|webp|gif|bmp)$/i.test(path);
return suffixPattern.test(path) || base64Pattern.test(path);
}

export default isImg;