Sha256: d8ce3069a367d533e2e3c132a8b68d50a6a2444caab4bca669253ff3e8e76230
Contents?: true
Size: 1.17 KB
Versions: 6
Compression:
Stored size: 1.17 KB
Contents
/* eslint-disable require-jsdoc */ /** * If you want to disable the warning but indicate that the link is an external * link, please define the `data-external-link-warning="false"` attribute for * the link, * e.g. <a href="https://..." target="_blank" data-external-link="text-only" data-external-domain-link="false">...</a> * * @param {HTMLElement} element The element for which to replace the link href for. * @returns {void} Nothing */ export default function updateExternalDomainLinks(element) { if (window.location.pathname === "/link") { return; } if (!element.hasAttribute("href") || element.closest(".editor-container")) { return; } if (element.dataset.externalDomainLink === "false") { return; } const parts = element.href.match(/^(([a-z]+):)?\/\/([^/:]+)(:[0-9]*)?(\/.*)?$/) || null; if (!parts) { return; } const domain = parts[3].replace(/^www\./, "") const allowlist = window.Decidim.config.get("external_domain_allowlist") || [] if (allowlist.includes(domain)) { return; } const externalHref = `/link?external_url=${encodeURIComponent(element.href)}`; element.href = externalHref; element.dataset.remote = true }
Version data entries
6 entries across 6 versions & 1 rubygems