openURL: handle urls with #
This commit is contained in:
parent
4a642f77a5
commit
a2ea1bb1d9
13
messaging.js
13
messaging.js
|
@ -150,16 +150,19 @@ function openURL({url, currentWindow = true}) {
|
||||||
url = chrome.runtime.getURL(url);
|
url = chrome.runtime.getURL(url);
|
||||||
}
|
}
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
chrome.tabs.query({url, currentWindow}, tabs => {
|
// API doesn't handle the hash-fragment part
|
||||||
if (tabs.length) {
|
chrome.tabs.query({url: url.replace(/#.*/, ''), currentWindow}, tabs => {
|
||||||
activateTab(tabs[0]).then(resolve);
|
for (const tab of tabs) {
|
||||||
} else {
|
if (tab.url == url) {
|
||||||
|
activateTab(tab).then(resolve);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
getActiveTab().then(tab => (
|
getActiveTab().then(tab => (
|
||||||
tab && tab.url == 'chrome://newtab/'
|
tab && tab.url == 'chrome://newtab/'
|
||||||
? chrome.tabs.update({url}, resolve)
|
? chrome.tabs.update({url}, resolve)
|
||||||
: chrome.tabs.create({url}, resolve)
|
: chrome.tabs.create({url}, resolve)
|
||||||
));
|
));
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user