Skip to content

Commit

Permalink
probably fix #2053
Browse files Browse the repository at this point in the history
  • Loading branch information
gorhill committed Oct 29, 2016
1 parent 50889da commit b2193a2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/js/messaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 14 additions & 2 deletions src/js/uritools.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

/* global publicSuffixList */

'use strict';

/*******************************************************************************
RFC 3986 as reference: http://tools.ietf.org/html/rfc3986#appendix-A
Expand All @@ -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/
Expand Down Expand Up @@ -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() {
Expand Down

1 comment on commit b2193a2

@gorhill
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment should be "probably fix #2105".

Please sign in to comment.