code review

pull/2/head
Raymond Hill 10 years ago
parent 44533d77eb
commit b62fb94a00

@ -92,6 +92,8 @@
return null; return null;
} }
var pageStore;
// https://github.com/gorhill/httpswitchboard/issues/303 // https://github.com/gorhill/httpswitchboard/issues/303
// Normalize to a page-URL. // Normalize to a page-URL.
pageURL = this.normalizePageURL(pageURL); pageURL = this.normalizePageURL(pageURL);
@ -99,6 +101,8 @@
// The previous page URL, if any, associated with the tab // The previous page URL, if any, associated with the tab
if ( this.tabIdToPageUrl.hasOwnProperty(tabId) ) { if ( this.tabIdToPageUrl.hasOwnProperty(tabId) ) {
var previousPageURL = this.tabIdToPageUrl[tabId]; var previousPageURL = this.tabIdToPageUrl[tabId];
// No change, do not rebind
if ( previousPageURL === pageURL ) { if ( previousPageURL === pageURL ) {
return this.pageStats[pageURL]; return this.pageStats[pageURL];
} }
@ -109,15 +113,17 @@
// https://github.com/gorhill/uMatrix/issues/72 // https://github.com/gorhill/uMatrix/issues/72
// Need to double-check that the new scope is same as old scope // Need to double-check that the new scope is same as old scope
var pageStore = this.pageStats[previousPageURL]; if ( context === 'pageUpdated' ) {
if ( context === 'pageUpdated' && pageStore.pageHostname === this.hostnameFromURL(pageURL) ) { pageStore = this.pageStats[previousPageURL];
pageStore.pageUrl = pageURL; if ( pageStore.pageHostname === this.hostnameFromURL(pageURL) ) {
delete this.pageStats[previousPageURL]; pageStore.pageUrl = pageURL;
this.pageStats[pageURL] = pageStore; delete this.pageStats[previousPageURL];
delete this.pageUrlToTabId[previousPageURL]; this.pageStats[pageURL] = pageStore;
this.pageUrlToTabId[pageURL] = tabId; delete this.pageUrlToTabId[previousPageURL];
this.tabIdToPageUrl[tabId] = pageURL; this.pageUrlToTabId[pageURL] = tabId;
return pageStore; this.tabIdToPageUrl[tabId] = pageURL;
return pageStore;
}
} }
} }

Loading…
Cancel
Save