aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorSaúl Ibarra Corretgé <s@saghul.net>2020-06-30 11:16:21 +0200
committerSaúl Ibarra Corretgé <s@saghul.net>2020-06-30 11:16:55 +0200
commitca1eb702507fdc4400fe21c905a9f85702f92a14 (patch)
tree72112e71ba5c234dbbd4c9d452e5ceade4ca0dff /app
parentdc3dd4459ae60d7cd3b203bffb3e1475769458d2 (diff)
Share logic for opening external links
Diffstat (limited to 'app')
-rw-r--r--app/features/utils/openExternalLink.js25
-rw-r--r--app/preload/preload.js27
2 files changed, 27 insertions, 25 deletions
diff --git a/app/features/utils/openExternalLink.js b/app/features/utils/openExternalLink.js
new file mode 100644
index 0000000..7694b53
--- /dev/null
+++ b/app/features/utils/openExternalLink.js
@@ -0,0 +1,25 @@
+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);
+ }
+}
diff --git a/app/preload/preload.js b/app/preload/preload.js
index 538b82f..ccc65cc 100644
--- a/app/preload/preload.js
+++ b/app/preload/preload.js
@@ -1,31 +1,9 @@
const createElectronStorage = require('redux-persist-electron-storage');
-const { ipcRenderer, shell, remote } = require('electron');
+const { ipcRenderer, remote } = require('electron');
const os = require('os');
-const url = require('url');
-
const jitsiMeetElectronUtils = require('jitsi-meet-electron-utils');
+const { openExternalLink } = require('../features/utils/openExternalLink');
-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);
- }
-}
const whitelistedIpcChannels = [ 'protocol-data-msg', 'renderer-ready' ];
@@ -34,7 +12,6 @@ window.jitsiNodeAPI = {
osUserInfo: os.userInfo,
openExternalLink,
jitsiMeetElectronUtils,
- shellOpenExternal: shell.openExternal,
getLocale: remote.app.getLocale,
ipc: {
on: (channel, listener) => {