From febbf61ffe646daf5dd466f4c801abbd60ff50b5 Mon Sep 17 00:00:00 2001 From: Joost Date: Fri, 18 Oct 2024 17:56:38 +0200 Subject: [PATCH] fix expression is always truthy --- src/main/index.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index c2b6b08..dad3bad 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -83,7 +83,6 @@ export async function createMainWindow() { }); if (process.env.VITE_DEV_SERVER_URL) { - // electron-vite-vue#298 await mainWindow.loadURL(devServerUrl); mainWindow.webContents.openDevTools({ mode: "detach" }); mainWindow.setMenuBarVisibility(false); @@ -104,13 +103,19 @@ export async function createMainWindow() { } mainWindow.webContents.setWindowOpenHandler(({ url }) => { - if (url.startsWith("https:" || "http:")) shell.openExternal(url); + if (url.startsWith("http:") || url.startsWith("https:")) { + shell.openExternal(url); + } return { action: "deny" }; }); + mainWindow.webContents.on( "will-navigate", (event: Electron.Event, url: string) => { - if (url.startsWith("https:" || "http:") && !url.includes("localhost")) { + if ( + (url.startsWith("http:") || url.startsWith("https:")) && + !url.includes("localhost") + ) { event.preventDefault(); shell.openExternal(url); }