From 847c3df7df84684e94c69db4fc1c67f5313c5d6f Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 11 Oct 2017 22:30:47 -0400 Subject: [PATCH] remove query string from manifest popup --- src/manifest.json | 2 +- src/popup/app/global/mainController.js | 10 ++++++++-- src/services/utilsService.js | 9 +++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/manifest.json b/src/manifest.json index cd19683809..f4dbbd1024 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -62,7 +62,7 @@ "38": "images/icon38.png" }, "default_title": "bitwarden", - "default_popup": "popup/index.html?uilocation=popup" + "default_popup": "popup/index.html" }, "permissions": [ "tabs", diff --git a/src/popup/app/global/mainController.js b/src/popup/app/global/mainController.js index 6bc1fe2361..f3bb2b4b4e 100644 --- a/src/popup/app/global/mainController.js +++ b/src/popup/app/global/mainController.js @@ -33,8 +33,14 @@ angular } if (chrome.windows.create) { - href = href.replace('uilocation=popup', 'uilocation=popout').replace('uilocation=tab', 'uilocation=popout') - .replace('uilocation=sidebar', 'uilocation=popout'); + if (href.indexOf('?uilocation=') > -1) { + href = href.replace('uilocation=popup', 'uilocation=popout').replace('uilocation=tab', 'uilocation=popout') + .replace('uilocation=sidebar', 'uilocation=popout'); + } + else { + var hrefParts = href.split('#'); + href = hrefParts[0] + '?uilocation=popout' + (hrefParts.length > 0 ? '#' + hrefParts[1] : ''); + } chrome.windows.create({ url: href, diff --git a/src/services/utilsService.js b/src/services/utilsService.js index e2004a0a5d..097e7d63a4 100644 --- a/src/services/utilsService.js +++ b/src/services/utilsService.js @@ -229,19 +229,20 @@ function initUtilsService() { }; UtilsService.prototype.inSidebar = function (theWindow) { - return theWindow.location.search && theWindow.location.search.indexOf('uilocation=sidebar') > -1; + return theWindow.location.search !== '' && theWindow.location.search.indexOf('uilocation=sidebar') > -1; }; UtilsService.prototype.inTab = function (theWindow) { - return theWindow.location.search && theWindow.location.search.indexOf('uilocation=tab') > -1; + return theWindow.location.search !== '' && theWindow.location.search.indexOf('uilocation=tab') > -1; }; UtilsService.prototype.inPopout = function (theWindow) { - return theWindow.location.search && theWindow.location.search.indexOf('uilocation=popout') > -1; + return theWindow.location.search !== '' && theWindow.location.search.indexOf('uilocation=popout') > -1; }; UtilsService.prototype.inPopup = function (theWindow) { - return theWindow.location.search && theWindow.location.search.indexOf('uilocation=popup') > -1; + return theWindow.location.search === '' || theWindow.location.search.indexOf('uilocation=') === -1 || + theWindow.location.search.indexOf('uilocation=popup') > -1; }; function validIpAddress(ipString) {