From df27e666a7580fba434f4bb9079aefd4d7c9e7da Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 12 Mar 2015 09:28:02 -0400 Subject: [PATCH] code review re #118 --- platform/chromium/vapi-background.js | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index 1792acd..5cf3707 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -200,19 +200,12 @@ vAPI.tabs.open = function(details) { return; } - chrome.tabs.query({}, function(tabs) { - var rgxHash = /#.*/; - // this is questionable - var url = targetURL.replace(rgxHash, ''); - var selected = tabs.some(function(tab) { - if ( tab.url.replace(rgxHash, '') === url ) { - chrome.tabs.update(tab.id, { active: true }); - chrome.windows.update(tab.windowId, { focused: true }); - return true; - } - }); - - if ( !selected ) { + chrome.tabs.query({ url: targetURL }, function(tabs) { + var tab = tabs[0]; + if ( tab ) { + chrome.windows.update(tab.windowId, { focused: true }); + chrome.tabs.update(tab.id, { active: true }); + } else { wrapper(); } });