1
0
Fork 0
mirror of https://github.com/gorhill/uMatrix.git synced 2024-06-29 11:30:20 +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,18 +96,21 @@
// Normalize to a page-URL. // Normalize to a page-URL.
pageURL = this.normalizePageURL(pageURL); pageURL = this.normalizePageURL(pageURL);
// The page URL, if any, currently associated with the tab // The previous page URL, if any, associated with the tab
if ( this.tabIdToPageUrl.hasOwnProperty(tabId) ) {
var previousPageURL = this.tabIdToPageUrl[tabId]; var previousPageURL = this.tabIdToPageUrl[tabId];
if ( previousPageURL === pageURL ) { if ( previousPageURL === pageURL ) {
return this.pageStats[pageURL]; return this.pageStats[pageURL];
} }
// https://github.com/gorhill/uMatrix/issues/37 // https://github.com/gorhill/uMatrix/issues/37
// Just rebind: the URL changed, but the document itself is the same. // Just rebind whenever possible: the URL changed, but the document maybe is the same.
// Example: Google Maps, Github // Example: Google Maps, Github
var pageStore;
if ( context === 'pageUpdated' && this.pageStats.hasOwnProperty(previousPageURL) ) { // https://github.com/gorhill/uMatrix/issues/72
pageStore = this.pageStats[previousPageURL]; // 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; pageStore.pageUrl = pageURL;
delete this.pageStats[previousPageURL]; delete this.pageStats[previousPageURL];
this.pageStats[pageURL] = pageStore; this.pageStats[pageURL] = pageStore;
@ -116,6 +119,7 @@
this.tabIdToPageUrl[tabId] = pageURL; this.tabIdToPageUrl[tabId] = pageURL;
return pageStore; return pageStore;
} }
}
pageStore = this.createPageStore(pageURL, context); pageStore = this.createPageStore(pageURL, context);