Skip to content

Commit 43b8d5a

Browse files
committed
fix: open external urls... externally
1 parent c2edd85 commit 43b8d5a

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/electron.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { app, BrowserWindow } = require('electron');
1+
const { app, BrowserWindow, shell } = require('electron');
22
const path = require('path');
33

44
function createWindow(dir = '') {
@@ -35,6 +35,20 @@ function createWindow(dir = '') {
3535
win.setFullScreen(!win.isFullScreen());
3636
}
3737
});
38+
39+
win.webContents.on('will-navigate', (event, url) => {
40+
const { host } = new URL(url);
41+
if (host === 'undercards.net') return;
42+
43+
event.preventDefault();
44+
if (host === 'www.undercards.net') {
45+
win.loadURL(url.replace('www.', ''));
46+
} else if (host === 'unpkg.com' && url.endsWith('undercards.user.js')) {
47+
// Trigger update
48+
} else {
49+
shell.openExternal(url);
50+
}
51+
});
3852
}
3953

4054
app.on('window-all-closed', () => {

0 commit comments

Comments
 (0)