1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-06-17 09:44:59 +12:00

this fixes #72

This commit is contained in:
Raymond Hill 2014-11-30 21:27:38 -02:00
parent e39b36beda
commit 44533d77eb

View file

@ -96,25 +96,29 @@
// Normalize to a page-URL.
pageURL = this.normalizePageURL(pageURL);
// The page URL, if any, currently associated with the tab
var previousPageURL = this.tabIdToPageUrl[tabId];
if ( previousPageURL === pageURL ) {
return this.pageStats[pageURL];
}
// The previous page URL, if any, associated with the tab
if ( this.tabIdToPageUrl.hasOwnProperty(tabId) ) {
var previousPageURL = this.tabIdToPageUrl[tabId];
if ( previousPageURL === pageURL ) {
return this.pageStats[pageURL];
}
// https://github.com/gorhill/uMatrix/issues/37
// Just rebind: the URL changed, but the document itself is the same.
// Example: Google Maps, Github
var pageStore;
if ( context === 'pageUpdated' && this.pageStats.hasOwnProperty(previousPageURL) ) {
pageStore = this.pageStats[previousPageURL];
pageStore.pageUrl = pageURL;
delete this.pageStats[previousPageURL];
this.pageStats[pageURL] = pageStore;
delete this.pageUrlToTabId[previousPageURL];
this.pageUrlToTabId[pageURL] = tabId;
this.tabIdToPageUrl[tabId] = pageURL;
return pageStore;
// https://github.com/gorhill/uMatrix/issues/37
// Just rebind whenever possible: the URL changed, but the document maybe is the same.
// Example: Google Maps, Github
// https://github.com/gorhill/uMatrix/issues/72
// Need to double-check that the new scope is same as old scope
var pageStore = this.pageStats[previousPageURL];
if ( context === 'pageUpdated' && pageStore.pageHostname === this.hostnameFromURL(pageURL) ) {
pageStore.pageUrl = pageURL;
delete this.pageStats[previousPageURL];
this.pageStats[pageURL] = pageStore;
delete this.pageUrlToTabId[previousPageURL];
this.pageUrlToTabId[pageURL] = tabId;
this.tabIdToPageUrl[tabId] = pageURL;
return pageStore;
}
}
pageStore = this.createPageStore(pageURL, context);