const { shell } = require('electron'); const url = require('url'); const protocolRegex = /^(https?|mailto):/i; /** * Opens the given link in an external browser. * * @param {string} link - The link (URL) that should be opened in the external browser. * @returns {void} */ export function openExternalLink(link) { let u; try { u = url.parse(link); } catch (e) { return; } if (protocolRegex.test(u.protocol)) { shell.openExternal(link); } }