summaryrefslogtreecommitdiff
path: root/ext/bg/js/backend.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2020-02-10 00:09:29 +0200
committersiikamiika <siikamiika@users.noreply.github.com>2020-02-10 00:09:29 +0200
commit56f1f8384dba7da6f1373768129bd37c24147520 (patch)
tree8a901ba14786075c7dba660dd01387eec05cfe8e /ext/bg/js/backend.js
parent4508efb9a695a97f19cf99ccb6155c55f9be5f0d (diff)
use parseUrl in Backend
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) {