Add: trimHash method
This commit is contained in:
parent
c1ea0d1a7d
commit
a026ccfb0b
|
@ -258,6 +258,14 @@ const APPLY = (() => {
|
||||||
case 'updateCount':
|
case 'updateCount':
|
||||||
updateCount();
|
updateCount();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'trimHash':
|
||||||
|
if (IS_OWN_PAGE) {
|
||||||
|
// FIXME: currently we only do this in our own page. Is it safe to do
|
||||||
|
// it on all pages?
|
||||||
|
history.pushState({preUrl: location.href}, null, ' ');
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* exported getActiveTab onTabReady stringAsRegExp getTabRealURL openURL
|
/* exported getActiveTab onTabReady stringAsRegExp getTabRealURL openURL
|
||||||
getStyleWithNoCode tryRegExp sessionStorageHash download deepEqual
|
getStyleWithNoCode tryRegExp sessionStorageHash download deepEqual
|
||||||
closeCurrentTab capitalize CHROME_HAS_BORDER_BUG */
|
closeCurrentTab capitalize CHROME_HAS_BORDER_BUG */
|
||||||
/* global promisify */
|
/* global promisify msg */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const CHROME = Boolean(chrome.app) && parseInt(navigator.userAgent.match(/Chrom\w+\/(?:\d+\.){2}(\d+)|$/)[1]);
|
const CHROME = Boolean(chrome.app) && parseInt(navigator.userAgent.match(/Chrom\w+\/(?:\d+\.){2}(\d+)|$/)[1]);
|
||||||
|
@ -248,9 +248,17 @@ function openURL(options) {
|
||||||
if (!tab) {
|
if (!tab) {
|
||||||
return getActiveTab().then(maybeReplace);
|
return getActiveTab().then(maybeReplace);
|
||||||
}
|
}
|
||||||
// update url if only hash is different
|
// update url if only hash is different?
|
||||||
if (tab.url !== url && tab.url.split('#')[0] === url.split('#')[0]) {
|
if (tab.url !== url && tab.url.split('#')[0] === url.split('#')[0]) {
|
||||||
return activateTab(tab, {url, index});
|
if (url.includes('#')) {
|
||||||
|
return activateTab(tab, {url, index});
|
||||||
|
} else {
|
||||||
|
// we can't update URL directly since it refresh the page
|
||||||
|
return Promise.all([
|
||||||
|
activateTab(tab, {index}),
|
||||||
|
msg.sendTab(tab.id, {method: 'trimHash'}).catch(console.warn)
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return activateTab(tab, {index});
|
return activateTab(tab, {index});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user