Skip to content

Commit e3239d2

Browse files
varunsharma27afc163
authored andcommitted
fix: #382 prevent network calls for the falsy/undefined src values inside isImageValid (#383)
1 parent 34482ab commit e3239d2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/util.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
export function isImageValid(src: string) {
22
return new Promise(resolve => {
3+
if (!src) {
4+
resolve(false);
5+
return;
6+
}
37
const img = document.createElement('img');
48
img.onerror = () => resolve(false);
59
img.onload = () => resolve(true);

0 commit comments

Comments
 (0)