jitsi-meet-electron/app/features/utils/openExternalLink.js
2020-06-30 11:16:55 +02:00

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);
}
}