mirror of
https://github.com/netzbegruenung/jitsi-meet-electron.git
synced 2024-05-05 10:13:41 +02:00
26 lines
488 B
JavaScript
26 lines
488 B
JavaScript
const { shell } = require('electron');
|
|
const url = require('url');
|
|
|
|
|
|
const protocolRegex = /^https?:/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);
|
|
}
|
|
}
|