blob: b31706149d31237d4cddffcdebd94e2a4eefe88b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
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);
}
}
|