Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jemikanegara committed Dec 6, 2024
1 parent 7c345c0 commit 3d17f22
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion utils/translation/startTranslationCycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 3d17f22

Please sign in to comment.