From e57ed992dfdca79d1e32d3966413587ef9da9f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Thu, 26 Jan 2023 12:59:34 +0100 Subject: fix(utils) make openExternalLink more resilient --- app/features/utils/openExternalLink.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/features/utils/openExternalLink.js b/app/features/utils/openExternalLink.js index b317061..e077ffa 100644 --- a/app/features/utils/openExternalLink.js +++ b/app/features/utils/openExternalLink.js @@ -2,8 +2,6 @@ const { shell } = require('electron'); const url = require('url'); -const protocolRegex = /^(https?|mailto):/i; - /** * Opens the given link in an external browser. * @@ -19,7 +17,10 @@ export function openExternalLink(link) { return; } - if (protocolRegex.test(u.protocol)) { - shell.openExternal(link); + const proto = u.protocol; + const href = u.href; + + if (proto === 'http:' || proto === 'https:' || proto === 'mailto:') { + shell.openExternal(href); } } -- cgit v1.2.3