From 3d17f22a6ecc9143b85dad5460dc129fd6bc796f Mon Sep 17 00:00:00 2001 From: jemikanegara Date: Fri, 6 Dec 2024 22:14:06 +0800 Subject: [PATCH] fix --- utils/translation/startTranslationCycle.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/utils/translation/startTranslationCycle.js b/utils/translation/startTranslationCycle.js index 275540d..920e020 100644 --- a/utils/translation/startTranslationCycle.js +++ b/utils/translation/startTranslationCycle.js @@ -4,6 +4,7 @@ const modifyHtmlStrings = require("./modifyHtmlStrings"); const { debounce } = require("../debounce"); const { renderSelectorState } = require("../selector/renderSelectorState"); const { isExcludedPath } = require("./isExcluded"); +const getUnprefixedPathname = require("../translation-mode/getUnprefixedPathname"); async function startTranslationCycle(window, node, apiKey, delay, shouldOptimizeSEO = false) { if (window.preventInitialTranslation) { @@ -93,7 +94,13 @@ async function startTranslationCycle(window, node, apiKey, delay, shouldOptimize const href = link.href; const url = new URL(href); const origin = url.origin; - if (origin == window.location.origin) { + + if (options.domainSourcePrefix) { + url.pathname = getUnprefixedPathname(window, options.domainSourcePrefix, url.pathname); + } + const isHashTagInSamePathname = url.href ? (url.pathname == window.location.pathname) && url.href.includes("#") : false; + + if (origin == window.location.origin && !isHashTagInSamePathname) { // add onclick link.onclick = (e) => { e.preventDefault();