From ddf1dc258a295db0c73836ef4321b5ebcae10fa4 Mon Sep 17 00:00:00 2001 From: James Tsay Date: Mon, 9 Dec 2024 23:49:58 -0800 Subject: [PATCH] Fix edge snippet fallback --- acrobat/blocks/dc-converter-widget/dc-converter-widget.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/acrobat/blocks/dc-converter-widget/dc-converter-widget.js b/acrobat/blocks/dc-converter-widget/dc-converter-widget.js index 5a0ef3b3..d356ac40 100644 --- a/acrobat/blocks/dc-converter-widget/dc-converter-widget.js +++ b/acrobat/blocks/dc-converter-widget/dc-converter-widget.js @@ -234,7 +234,7 @@ export default async function init(element) { const preRenderDropZone = !isLimitExhausted && !isRedirection; const INLINE_SNIPPET = widget.querySelector(':scope > section#edge-snippet'); - if (INLINE_SNIPPET) { + if (INLINE_SNIPPET && INLINE_SNIPPET.childNodes.length > 0) { if (!isLimitExhausted) { widgetContainer.dataset.rendered = 'true'; widgetContainer.appendChild(...INLINE_SNIPPET.childNodes); @@ -242,7 +242,9 @@ export default async function init(element) { } widget.removeChild(INLINE_SNIPPET); } else if (preRenderDropZone) { - const response = await fetch(DC_GENERATE_CACHE_URL || `${DC_DOMAIN}/dc-generate-cache/dc-hosted-${DC_GENERATE_CACHE_VERSION}/${VERB}-${pageLang}.html`); + const cacheHost = new URL(WIDGET_ENV); + cacheHost.pathname = ''; + const response = await fetch(DC_GENERATE_CACHE_URL || `${cacheHost}dc-generate-cache/dc-hosted-${DC_GENERATE_CACHE_VERSION}/${VERB}-${pageLang}.html`); switch (response.status) { case 200: { const template = await response.text();