Open links in external browser

This commit is contained in:
Sal van Wezel
2026-06-02 17:26:49 +02:00
parent fcd994c9f7
commit 98568515ea
+9 -1
View File
@@ -1,4 +1,4 @@
const { app, BrowserWindow, session, globalShortcut } = require('electron');
const { app, BrowserWindow, session, globalShortcut, shell } = require('electron');
const fs = require('fs');
const path = require('path');
@@ -68,6 +68,14 @@ const createWindow = () => {
win.setMenu(null);
win.loadURL('https://linear.app/login');
const authPatterns = ['/oauth', '/auth', '/login', '/signin', '/sso', '/saml', '/callback'];
win.webContents.setWindowOpenHandler(({ url }) => {
const isAuth = authPatterns.some(p => url.includes(p));
if (isAuth) return { action: 'allow' };
shell.openExternal(url);
return { action: 'deny' };
});
win.on('close', () => {
saveWindowState(win.getBounds());
});