Skip to content

Commit 8c18ad9

Browse files
committed
perf: is utils
1 parent 5da9b66 commit 8c18ad9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/utils/is.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,12 @@ export const isUrl = (path: string): boolean => {
103103
export const isDark = (): boolean => {
104104
return window.matchMedia('(prefers-color-scheme: dark)').matches
105105
}
106+
107+
// 是否是图片链接
108+
export const isImgPath = (path: string): boolean => {
109+
return /(https?:\/\/|data:image\/).*?\.(png|jpg|jpeg|gif|svg|webp|ico)/gi.test(path)
110+
}
111+
112+
export const isEmptyVal = (val: any): boolean => {
113+
return val === '' || val === null || val === undefined
114+
}

0 commit comments

Comments
 (0)