Skip to content

Commit

Permalink
Merge pull request #2122 from bfmvsa/open-links-in-default-browser
Browse files Browse the repository at this point in the history
Fix issue with opening external links in app's window.
  • Loading branch information
mmosca authored Jun 27, 2024
2 parents 732817b + 09ef90d commit a7625bf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app, BrowserWindow, ipcMain, Menu, MenuItem } = require('electron');
const { app, BrowserWindow, ipcMain, Menu, MenuItem, shell } = require('electron');
const windowStateKeeper = require('electron-window-state');
const path = require('path');
const Store = require('electron-store');
Expand Down Expand Up @@ -148,6 +148,12 @@ function createWindow() {
});

mainWindow.webContents.setWindowOpenHandler(({ url }) => {
// Open links starts with https:// in default browser
if (url.startsWith('https://')) {
shell.openExternal(url);
return { action: 'deny' };
}

return {
action: 'allow',
overrideBrowserWindowOptions: {
Expand Down

0 comments on commit a7625bf

Please sign in to comment.