aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/background/tabs.js18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/background/tabs.js b/src/background/tabs.js
index 201fa73..617909e 100644
--- a/src/background/tabs.js
+++ b/src/background/tabs.js
@@ -33,19 +33,17 @@ const selectAt = (index) => {
const selectByKeyword = (keyword) => {
chrome.tabs.query({ currentWindow: true }, (tabs) => {
- let tab = tabs.find((tab) => tab.url.includes(keyword))
- if (tab) {
- chrome.tabs.update(tab.id, { active: true });
- return;
- }
+ let matched = tabs.filter((t) => {
+ return t.url.includes(keyword) || t.title.includes(keyword)
+ })
- tab = tabs.find((tab) => tab.title.includes(keyword))
- if (tab) {
- chrome.tabs.update(tab.id, { active: true });
- return;
+ if (matched.length == 0) {
+ throw new RangeError('No matching buffer for ' + keyword);
+ } else if (matched.length >= 2) {
+ throw new RangeError('More than one match for ' + keyword);
}
- throw new RangeError('No matching buffer for ' + keyword);
+ chrome.tabs.update(matched[0].id, { active: true });
})
}