aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/backend.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r--ext/bg/js/backend.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index 9eb1d9ca..9565a8d9 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -608,14 +608,16 @@ class Backend {
const queryString = new URLSearchParams(queryParams).toString();
const url = `${baseUrl}?${queryString}`;
+ const isTabMatch = (url2) => {
+ if (url2 === null || !url2.startsWith(baseUrl)) { return false; }
+ const {baseUrl: baseUrl2, queryParams: queryParams2} = parseUrl(url2);
+ return baseUrl2 === baseUrl && (queryParams2.mode === mode || (!queryParams2.mode && mode === 'existingOrNewTab'));
+ };
+
switch (mode) {
case 'existingOrNewTab':
try {
- const tab = await Backend._findTab(1000, (url2) => (
- url2 !== null &&
- url2.startsWith(baseUrl) &&
- (url2.length === baseUrl.length || url2[baseUrl.length] === '?' || url2[baseUrl.length] === '#')
- ));
+ const tab = await Backend._findTab(1000, isTabMatch);
if (tab !== null) {
await Backend._focusTab(tab);
if (queryParams.query) {