Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restrict URLs which can be opened in an external browser
- Loading branch information
Showing
2 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,37 @@ | ||
const createElectronStorage = require('redux-persist-electron-storage'); | ||
const { shell } = require('electron'); | ||
const os = require('os'); | ||
const url = require('url'); | ||
|
||
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 = { | ||
createElectronStorage, | ||
osUserInfo: os.userInfo, | ||
shellOpenExternal: shell.openExternal, | ||
openExternalLink, | ||
jitsiMeetElectronUtils | ||
}; | ||
|