Skip to content

Commit

Permalink
fix opening blank window links
Browse files Browse the repository at this point in the history
fixes #176
  • Loading branch information
timche committed Dec 19, 2019
1 parent 771e0b2 commit 10ec7e2
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,10 @@ app.on('ready', () => {
// `Add account` opens `accounts.google.com`
if (url.startsWith('https://accounts.google.com')) {
mainWindow.loadURL(url)
} else if (url.startsWith('https://mail.google.com')) {
return
}

if (url.startsWith('https://mail.google.com')) {
// Check if the user switches accounts which is determined
// by the URL: `mail.google.com/mail/u/<local_account_id>/...`
const currentAccountId = getUrlAccountId(mainWindow.webContents.getURL())
Expand Down Expand Up @@ -254,9 +257,25 @@ app.on('ready', () => {
shell.openExternal(url)
}
)
} else {
shell.openExternal(url)

return
}

if (url.startsWith('about:blank')) {
const win = new BrowserWindow({
...options,
show: false
})

win.webContents.once('will-redirect', (_event, url) => {
shell.openExternal(url)
win.destroy()
})

event.newGuest = win
}

shell.openExternal(url)
})
})

Expand Down

0 comments on commit 10ec7e2

Please sign in to comment.