Skip to content

Commit

Permalink
fix(utils) make openExternalLink more resilient
Browse files Browse the repository at this point in the history
  • Loading branch information
saghul committed Jan 31, 2023
1 parent 097214d commit e57ed99
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/features/utils/openExternalLink.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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);
}
}

0 comments on commit e57ed99

Please sign in to comment.