[MM-50410] Allow any unhandled target=_blank links to open in the browser (#2548)

This commit is contained in:
Devin Binnie 2023-02-09 09:03:32 -05:00 committed by GitHub
parent 06eb76dc21
commit 6dca4a5095
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View file

@ -250,5 +250,11 @@ describe('main/views/webContentsEvents', () => {
expect(newWindow({url: 'http://server-1.com/trusted/login'})).toStrictEqual({action: 'deny'});
expect(webContentsEventManager.popupWindow).toBeTruthy();
});
it('should open external URIs in browser', () => {
urlUtils.isValidURI.mockReturnValue(false);
expect(newWindow({url: 'https://google.com'})).toStrictEqual({action: 'deny'});
expect(shell.openExternal).toBeCalledWith('https://google.com');
});
});
});

View file

@ -133,7 +133,6 @@ export class WebContentsEventManager {
}
const serverURL = WindowManager.getServerURLFromWebContentsId(webContentsId);
if (!serverURL) {
shell.openExternal(details.url);
return {action: 'deny'};
@ -206,8 +205,12 @@ export class WebContentsEventManager {
const contextMenu = new ContextMenu({}, this.popupWindow);
contextMenu.reload();
return {action: 'deny'};
}
// If all else fails, just open externally
shell.openExternal(details.url);
return {action: 'deny'};
};
};