From f2e71daa46f23812ef4442178a3722227fe08540 Mon Sep 17 00:00:00 2001 From: Varun Sharma Date: Fri, 14 Mar 2025 12:19:22 +0000 Subject: [PATCH] fix: #382 prevent network calls for the falsy/undefined src values inside isImageValid --- src/util.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util.ts b/src/util.ts index 9f44fef..e0b77ae 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,5 +1,9 @@ export function isImageValid(src: string) { return new Promise(resolve => { + if (!src) { + resolve(false); + return; + } const img = document.createElement('img'); img.onerror = () => resolve(false); img.onload = () => resolve(true);