From b6e6970e0edb4749c52004bba8f24057e3badcfe Mon Sep 17 00:00:00 2001 From: LeopoldTal Date: Sat, 31 Oct 2020 12:21:39 +0100 Subject: [PATCH] use electron builtin to open links (#897) When opening a link on standalone, use [shell.openExternal](https://github.com/electron/electron/blob/master/docs/api/shell.md#shellopenexternalurl-options). This works cross-platform, and looks less suspicious to antivirus than explicitly shelling out. --- electron/index.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/electron/index.js b/electron/index.js index 7b9377df..91ab8e9e 100644 --- a/electron/index.js +++ b/electron/index.js @@ -4,7 +4,7 @@ const { app, BrowserWindow, Menu, MenuItem, session } = require("electron"); const path = require("path"); const url = require("url"); const childProcess = require("child_process"); -const { ipcMain } = require("electron"); +const { ipcMain, shell } = require("electron"); const fs = require("fs"); const isDev = process.argv.indexOf("--dev") >= 0; const isLocal = process.argv.indexOf("--local") >= 0; @@ -67,11 +67,7 @@ function createWindow() { win.webContents.on("new-window", (event, pth) => { event.preventDefault(); - if (process.platform == "win32") { - childProcess.execSync("start " + pth); - } else if (process.platform == "linux") { - childProcess.execSync("xdg-open " + pth); - } + shell.openExternal(pth); }); win.on("closed", () => {