Skip to content

Commit

Permalink
include prefix for relative src
Browse files Browse the repository at this point in the history
  • Loading branch information
jemikanegara committed Nov 28, 2024
1 parent 990fa3e commit 1eff3fa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions utils/translation/startTranslationCycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@ async function startTranslationCycle(window, node, apiKey, delay, shouldOptimize
const [srcUrl, srcWidth] = src.split(" ");
const url = new URL(srcUrl, window.location.origin);
url.hostname = originalWebsiteHostname;
if (options.domainSourcePrefix) {
url.pathname = `${options.domainSourcePrefix}${url.pathname}`;
}
return `${url.href} ${srcWidth}`;
}).join(", ");
el.srcset = newSrcset;
} else {
const url = new URL(el[attr]);
url.hostname = originalWebsiteHostname;
if (options.domainSourcePrefix) {
url.pathname = `${options.domainSourcePrefix}${url.pathname}`;
}
el[attr] = url.href;
}
})
Expand Down

0 comments on commit 1eff3fa

Please sign in to comment.