From c4b1ab0f6454ef8d7b806e86a212b8bb5ce11191 Mon Sep 17 00:00:00 2001 From: Sebastian Helzle Date: Wed, 15 Feb 2023 09:15:56 +0100 Subject: [PATCH] BUGFIX: Prevent opening relative urls in new tab --- packages/commandbar/src/state/CommandBarInputProvider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/commandbar/src/state/CommandBarInputProvider.tsx b/packages/commandbar/src/state/CommandBarInputProvider.tsx index 41c5c5e..579987c 100644 --- a/packages/commandbar/src/state/CommandBarInputProvider.tsx +++ b/packages/commandbar/src/state/CommandBarInputProvider.tsx @@ -83,7 +83,7 @@ export const CommandBarInputProvider: React.FC = ({ ch // We need to check if the url is in the same domain, otherwise we need to open it in a new tab // TODO: We should add another option to a link command to define its target - if (action.indexOf(document.location.origin) !== 0) { + if (action.indexOf('http') === 0 && action.indexOf(document.location.origin) !== 0) { window.open(action, '_blank', 'noopener,noreferrer')?.focus(); } else { window.location.href = action;