From 4777d69cd704e04644a88ec9faf8c39857c06976 Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Mon, 9 Sep 2024 11:02:32 +0000 Subject: [PATCH] web/OuterLink: don't set target/rel for relative links --- web/src/components/misc/OuterLink.svelte | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web/src/components/misc/OuterLink.svelte b/web/src/components/misc/OuterLink.svelte index 48f6f614..ac10291d 100644 --- a/web/src/components/misc/OuterLink.svelte +++ b/web/src/components/misc/OuterLink.svelte @@ -5,8 +5,17 @@ // no way to change this behavior atm (https://github.com/pngwn/MDsveX/issues/609) export let rel: string = ""; rel; + + const [ target, _rel ] = (() => { + try { + new URL(href) + return [ '_blank', 'noopener noreferrer' ]; + } catch {} + + return []; + })(); - +