handle chrome:// scheme in openURL()

This commit is contained in:
tophf 2018-03-22 03:09:20 +03:00
parent b185140176
commit 89d4bb1ed4

View File

@ -375,7 +375,10 @@ function openURL({
// FF doesn't handle moz-extension:// URLs (bug) // FF doesn't handle moz-extension:// URLs (bug)
// FF decodes %2F in encoded parameters (bug) // FF decodes %2F in encoded parameters (bug)
// API doesn't handle the hash-fragment part // 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') ? FIREFOX && url.includes('%2F') ?
url.replace(/%2F.*/, '*').replace(/#.*/, '') : url.replace(/%2F.*/, '*').replace(/#.*/, '') :
url.replace(/#.*/, ''); url.replace(/#.*/, '');
@ -391,8 +394,9 @@ function openURL({
} }
function maybeSwitch(tabs = []) { function maybeSwitch(tabs = []) {
const urlWithSlash = url + '/';
const urlFF = FIREFOX && url.replace(/%2F/g, '/'); 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) { if (!tab) {
return getActiveTab().then(maybeReplace); return getActiveTab().then(maybeReplace);
} }