mirror of
https://github.com/netzbegruenung/jitsi-meet-electron.git
synced 2024-05-13 14:06:06 +02:00
Restrict URLs which can be opened in an external browser
This commit is contained in:
parent
27fc58f927
commit
962470d97e
|
@ -52,5 +52,5 @@ export function normalizeServerURL(url: string) {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
export function openExternalLink(link: string) {
|
export function openExternalLink(link: string) {
|
||||||
window.jitsiNodeAPI.shellOpenExternal(link);
|
window.jitsiNodeAPI.openExternalLink(link);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,37 @@
|
||||||
const createElectronStorage = require('redux-persist-electron-storage');
|
const createElectronStorage = require('redux-persist-electron-storage');
|
||||||
const { shell } = require('electron');
|
const { shell } = require('electron');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
|
const url = require('url');
|
||||||
|
|
||||||
const jitsiMeetElectronUtils = require('jitsi-meet-electron-utils');
|
const jitsiMeetElectronUtils = require('jitsi-meet-electron-utils');
|
||||||
|
|
||||||
|
|
||||||
|
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}
|
||||||
|
*/
|
||||||
|
function openExternalLink(link) {
|
||||||
|
let u;
|
||||||
|
|
||||||
|
try {
|
||||||
|
u = url.parse(link);
|
||||||
|
} catch (e) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (protocolRegex.test(u.protocol)) {
|
||||||
|
shell.openExternal(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
window.jitsiNodeAPI = {
|
window.jitsiNodeAPI = {
|
||||||
createElectronStorage,
|
createElectronStorage,
|
||||||
osUserInfo: os.userInfo,
|
osUserInfo: os.userInfo,
|
||||||
shellOpenExternal: shell.openExternal,
|
openExternalLink,
|
||||||
jitsiMeetElectronUtils
|
jitsiMeetElectronUtils
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue