From 7d511db479792513304ee2f00dd44a0fd9f90655 Mon Sep 17 00:00:00 2001 From: Jonas Brunvoll Larsson Date: Tue, 26 Nov 2024 11:24:57 +0100 Subject: [PATCH] Navigate to new tab if link is external. --- src/layouts/shared/footer.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/layouts/shared/footer.tsx b/src/layouts/shared/footer.tsx index aef023d3..9593b94a 100644 --- a/src/layouts/shared/footer.tsx +++ b/src/layouts/shared/footer.tsx @@ -17,7 +17,7 @@ type SomeLink = { title: string; }; -const { orgId, urls, fylkeskommune } = getOrgData(); +const { urls, fylkeskommune } = getOrgData(); export default function Footer({ withoutSettings = false }: FooterProps) { const { isDarkMode, toggleDarkmode } = useTheme(); @@ -92,7 +92,11 @@ export default function Footer({ withoutSettings = false }: FooterProps) {
  • {t( @@ -247,3 +251,13 @@ function LanguageSelections() { ); } + +function isExternalUrl(url: string) { + try { + const currentHostname = window.location.hostname; + const urlHostname = new URL(url).hostname; + return urlHostname !== currentHostname; + } catch { + return false; + } +}