diff --git a/src/js/messaging.js b/src/js/messaging.js index 654c71f28..be1a23ff9 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -309,6 +309,17 @@ var popupDataFromTabId = function(tabId, tabTitle) { var pageStore = µb.pageStoreFromTabId(tabId); if ( pageStore ) { + // https://github.com/gorhill/uBlock/issues/2105 + // Be sure to always include the current page's hostname -- it might + // not be present when the page itself is pulled from the browser's + // short-term memory cache. This needs to be done before calling + // getHostnameDict(). + if ( + pageStore.hostnameToCountMap.has(rootHostname) === false && + µb.URI.isNetworkURI(tabContext.rawURL) + ) { + pageStore.hostnameToCountMap.set(rootHostname, 0); + } r.pageBlockedRequestCount = pageStore.perLoadBlockedRequestCount; r.pageAllowedRequestCount = pageStore.perLoadAllowedRequestCount; r.netFilteringSwitch = pageStore.getNetFilteringSwitch(); diff --git a/src/js/uritools.js b/src/js/uritools.js index 9bd1271a8..661d6c608 100644 --- a/src/js/uritools.js +++ b/src/js/uritools.js @@ -21,6 +21,8 @@ /* global publicSuffixList */ +'use strict'; + /******************************************************************************* RFC 3986 as reference: http://tools.ietf.org/html/rfc3986#appendix-A @@ -33,8 +35,6 @@ Naming convention from https://en.wikipedia.org/wiki/URI_scheme#Examples µBlock.URI = (function() { -'use strict'; - /******************************************************************************/ // Favorite regex tool: http://regex101.com/ @@ -402,6 +402,18 @@ URI.domainFromURI = function(uri) { /******************************************************************************/ +URI.isNetworkURI = function(uri) { + return /^(?:ftps?|https?|wss?):\/\//.test(uri); +}; + +/******************************************************************************/ + +URI.isNetworkScheme = function(scheme) { + return /^(?:ftps?|https?|wss?)$/.test(scheme); +}; + +/******************************************************************************/ + // Normalize the way µBlock expects it URI.normalizedURI = function() {