From 89d4bb1ed43d629c40cfcc36eada0b02e2650d9d Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 22 Mar 2018 03:09:20 +0300 Subject: [PATCH] handle chrome:// scheme in openURL() --- js/messaging.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/messaging.js b/js/messaging.js index a46b3a16..d0fad132 100644 --- a/js/messaging.js +++ b/js/messaging.js @@ -375,7 +375,10 @@ function openURL({ // FF doesn't handle moz-extension:// URLs (bug) // FF decodes %2F in encoded parameters (bug) // API doesn't handle the hash-fragment part - const urlQuery = url.startsWith('moz-extension') ? undefined : + const urlQuery = + url.startsWith('moz-extension') || + url.startsWith('chrome:') ? + undefined : FIREFOX && url.includes('%2F') ? url.replace(/%2F.*/, '*').replace(/#.*/, '') : url.replace(/#.*/, ''); @@ -391,8 +394,9 @@ function openURL({ } function maybeSwitch(tabs = []) { + const urlWithSlash = url + '/'; const urlFF = FIREFOX && url.replace(/%2F/g, '/'); - const tab = tabs.find(tab => tab.url === url || tab.url === urlFF); + const tab = tabs.find(({url: u}) => u === url || u === urlFF || u === urlWithSlash); if (!tab) { return getActiveTab().then(maybeReplace); }