From 74513003e0c8645ff4b0de1a396b03835e9361fd Mon Sep 17 00:00:00 2001 From: jemikanegara Date: Mon, 21 Oct 2024 02:47:19 +0800 Subject: [PATCH] fix srcset url --- utils/translation/startTranslationCycle.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/translation/startTranslationCycle.js b/utils/translation/startTranslationCycle.js index 326739a..d7b0f4d 100644 --- a/utils/translation/startTranslationCycle.js +++ b/utils/translation/startTranslationCycle.js @@ -29,7 +29,7 @@ async function startTranslationCycle(window, node, apiKey, delay, shouldOptimize // replace the hostname of the src with the original hostname elementsWithRelativeSrc.forEach(el => { // use URL class - const url = new URL(el[attr]); + const url = new URL(attr == "srcset" ? `${window.location.origin}/${el.srcset.startsWith("/") ? el.slice(1) : el}` : el.src); url.hostname = originalWebsiteHostname; el[attr] = url.href; })