ELECTRON-1050: fix issue where we were opening new window for same pod url (#577)

This commit is contained in:
Vishwas Shashidhar 2019-03-04 19:04:35 +05:30 committed by GitHub
parent ae508da377
commit b40c2787bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -454,7 +454,17 @@ function doCreateMainWindow(initialUrl, initialBounds, isCustomTitleBar) {
let emptyUrlString = 'about:blank';
let dispositionWhitelist = ['new-window', 'foreground-tab'];
// only allow window.open to succeed is if coming from same hsot,
let fullMainUrl = `${mainWinParsedUrl.protocol}//${mainWinParsedUrl.host}/`;
// If the main url and new window url are the same,
// we open that in a browser rather than a separate window
if (newWinUrl === fullMainUrl) {
event.preventDefault();
openUrlInDefaultBrowser(newWinUrl);
return;
}
// only allow window.open to succeed is if coming from same host,
// otherwise open in default browser.
if ((newWinHost === mainWinHost || newWinUrl === emptyUrlString) && dispositionWhitelist.includes(disposition)) {
// handle: window.open