aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaúl Ibarra Corretgé <s@saghul.net>2023-01-26 12:59:34 +0100
committerSaúl Ibarra Corretgé <s@saghul.net>2023-01-31 14:14:01 +0100
commite57ed992dfdca79d1e32d3966413587ef9da9f22 (patch)
tree6f1a70f21c86813f84716ef2198c4c2cb19ae9e2
parent097214dea1885ec10c4697bd40e9464942b5c28c (diff)
fix(utils) make openExternalLink more resilient
-rw-r--r--app/features/utils/openExternalLink.js9
1 files changed, 5 insertions, 4 deletions
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);
}
}