From ab5d67eacb0fc2492e89f09c64fb07b893c1489d Mon Sep 17 00:00:00 2001 From: garywill Date: Sun, 14 Mar 2021 19:01:37 +0800 Subject: [PATCH] fix can't open in default container if url assigned to a container associate userContextId=0 with CookieStoreId="firefox-default" --- src/js/background/assignManager.js | 5 ++--- src/js/background/backgroundLogic.js | 5 ++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/js/background/assignManager.js b/src/js/background/assignManager.js index 032adb1..d2aa804 100644 --- a/src/js/background/assignManager.js +++ b/src/js/background/assignManager.js @@ -705,9 +705,8 @@ window.assignManager = { return browser.tabs.create({url, cookieStoreId, index, active, openerTabId}); } else { let confirmUrl = `${loadPage}?url=${this.encodeURLProperty(url)}&cookieStoreId=${cookieStoreId}`; - let currentCookieStoreId; - if (currentUserContextId) { - currentCookieStoreId = backgroundLogic.cookieStoreId(currentUserContextId); + const currentCookieStoreId = backgroundLogic.cookieStoreId(currentUserContextId); + if (parseInt(currentUserContextId, 10) > 0) { confirmUrl += `¤tCookieStoreId=${currentCookieStoreId}`; } return browser.tabs.create({ diff --git a/src/js/background/backgroundLogic.js b/src/js/background/backgroundLogic.js index 7643221..d0ef360 100644 --- a/src/js/background/backgroundLogic.js +++ b/src/js/background/backgroundLogic.js @@ -32,6 +32,9 @@ const backgroundLogic = { if (!cookieStoreId) { return false; } + if (cookieStoreId === "firefox-default") { + return "0"; + } const container = cookieStoreId.replace("firefox-container-", ""); if (container !== cookieStoreId) { return container; @@ -357,7 +360,7 @@ const backgroundLogic = { }, cookieStoreId(userContextId) { - if(userContextId === 0) return "firefox-default"; + if (parseInt(userContextId, 10) === 0) return "firefox-default"; return `firefox-container-${userContextId}`; } };