From e94b85ce09520e003d4e4fe84ce7f6d82eb0231e Mon Sep 17 00:00:00 2001 From: John Factotum <50942278+johnfactotum@users.noreply.github.com> Date: Wed, 25 Sep 2024 23:15:02 +0800 Subject: [PATCH] FB2: don't throw when image has no xlink:href Fixes #35 --- fb2.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fb2.js b/fb2.js index d21a5a9..49d7231 100644 --- a/fb2.js +++ b/fb2.js @@ -71,7 +71,9 @@ const BODY = { const getImageSrc = el => { const href = el.getAttributeNS(NS.XLINK, 'href') + if (!href) return 'data:,' const [, id] = href.split('#') + if (!id) return href const bin = el.getRootNode().getElementById(id) return bin ? `data:${bin.getAttribute('content-type')};base64,${bin.textContent}`