aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhackademix <giorgio@maone.net>2018-11-03 15:13:22 +0100
committerhackademix <giorgio@maone.net>2018-11-03 15:13:22 +0100
commit1da6959e3ca0def2d6d8905d69e4b327cf417a0a (patch)
tree618a9e1657a9dfc7ef5285a0e9becbfb1d61255a
parent2eb42923521bcbe2e5bf233736bec64733542bdf (diff)
URL matching for report data should ignore hash component.
-rw-r--r--main_background.js19
1 files changed, 9 insertions, 10 deletions
diff --git a/main_background.js b/main_background.js
index 06fd6cb..35daf4b 100644
--- a/main_background.js
+++ b/main_background.js
@@ -129,7 +129,10 @@ function options_listener(changes, area){
var activeMessagePorts = {};
var activityReports = {};
-async function createReport(initializer = null) {
+async function createReport(initializer) {
+ if (!(initializer && (initializer.url || initializer.tabId))) {
+ throw new Error("createReport() needs an URL or a tabId at least");
+ }
let template = {
"accepted": [],
"blocked": [],
@@ -137,14 +140,10 @@ async function createReport(initializer = null) {
"whitelisted": [],
"unknown": [],
};
- if (initializer) {
- template = Object.assign(template, initializer);
- if (!template.url && initializer.tabId) {
- template.url = (await browser.tabs.get(initializer.tabId)).url;
- }
- }
-
- template.site = ListStore.siteItem(template.url);
+ template = Object.assign(template, initializer);
+ let [url] = (template.url || (await browser.tabs.get(initializer.tabId)).url).split("#");
+ template.url = url;
+ template.site = ListStore.siteItem(url);
template.siteStatus = listManager.getStatus(template.site);
return template;
}
@@ -417,7 +416,7 @@ function delete_removed_tab_info(tab_id, remove_info){
*/
async function onTabUpdated(tabId, changedInfo, tab) {
- let url = tab.url.replace(/#.*/, '');
+ let [url] = tab.url.split("#");
let report = activityReports[tabId];
if (!(report && report.url === url)) {
let cache = await browser.sessions.getTabValue(tabId, url);