From b40c2787bfe8cfb67ea87a0d9897ec2b30d1ddfa Mon Sep 17 00:00:00 2001 From: Vishwas Shashidhar Date: Mon, 4 Mar 2019 19:04:35 +0530 Subject: [PATCH] ELECTRON-1050: fix issue where we were opening new window for same pod url (#577) --- js/windowMgr.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/windowMgr.js b/js/windowMgr.js index 1d0604eb..dd78dcc9 100644 --- a/js/windowMgr.js +++ b/js/windowMgr.js @@ -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