From 901c325eabcc2736119ffef46ffc2d978107c969 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Mon, 20 May 2019 12:07:02 -0400 Subject: [PATCH] Use documentUrl for context purpose when available Related issue: - https://github.com/uBlockOrigin/uMatrix-issues/issues/155 documentUrl was currently used on onBeforeRequest but not for onBeforeSendHeaders. --- .jshintrc | 1 + src/js/traffic.js | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.jshintrc b/.jshintrc index a7b9bc0..87cb055 100644 --- a/.jshintrc +++ b/.jshintrc @@ -10,6 +10,7 @@ "vAPI": false, "µMatrix": false }, + "laxbreak": true, "strict": "global", "undef": true, "unused": true, diff --git a/src/js/traffic.js b/src/js/traffic.js index 3b5da78..3186df1 100644 --- a/src/js/traffic.js +++ b/src/js/traffic.js @@ -196,12 +196,16 @@ var onBeforeSendHeadersHandler = function(details) { // to scope on unknown scheme? Etc. // https://github.com/gorhill/httpswitchboard/issues/191 // https://github.com/gorhill/httpswitchboard/issues/91#issuecomment-37180275 - let tabId = details.tabId, - pageStore = µm.mustPageStoreFromTabId(tabId), - srcHn = pageStore.pageHostname, - desHn = µmuri.hostnameFromURI(desURL), - requestType = requestTypeNormalizer[details.type] || 'other', - requestHeaders = details.requestHeaders; + const tabId = details.tabId; + const pageStore = µm.mustPageStoreFromTabId(tabId); + const desHn = µmuri.hostnameFromURI(desURL); + const requestType = requestTypeNormalizer[details.type] || 'other'; + const requestHeaders = details.requestHeaders; + + // https://github.com/uBlockOrigin/uMatrix-issues/issues/155 + // TODO: import all filtering context improvements from uBO. + const srcHn = µmuri.hostnameFromURI(details.documentUrl) || + pageStore.pageHostname; // https://github.com/gorhill/httpswitchboard/issues/342 // Is this hyperlink auditing?