From e0b8cf24d10ad9631fb8efd6b2aa4f9a52029ee3 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sat, 24 Aug 2019 13:48:50 -0400 Subject: [PATCH] Clear internal cache when loading redirect rules Related commit: - 3e5c9e00ab3603ae0c02e08b007b084404bbb71d This fix a regression: newly added redirect rules could end up not being taken into account unless uBO was restarted. --- src/js/redirect-engine.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/js/redirect-engine.js b/src/js/redirect-engine.js index c2e053a5c..4825588a8 100644 --- a/src/js/redirect-engine.js +++ b/src/js/redirect-engine.js @@ -266,13 +266,6 @@ const RedirectEngine = function() { this.resources = new Map(); this.reset(); this.resourceNameRegister = ''; - - // Internal use - this._missedQueryHash = ''; - this._src = ''; - this._srcAll = [ '*' ]; - this._des = ''; - this._desAll = [ '*' ]; }; /******************************************************************************/ @@ -281,9 +274,18 @@ RedirectEngine.prototype.reset = function() { this.rules = new Map(); this.ruleSources = new Set(); this.ruleDestinations = new Set(); + this.resetCache(); this.modifyTime = Date.now(); }; +RedirectEngine.prototype.resetCache = function() { + this._missedQueryHash = ''; + this._src = ''; + this._srcAll = [ '*' ]; + this._des = ''; + this._desAll = [ '*' ]; +}; + /******************************************************************************/ RedirectEngine.prototype.freeze = function() { @@ -594,6 +596,7 @@ RedirectEngine.prototype.fromSelfie = function(path) { this.rules = new Map(selfie.rules); this.ruleSources = new Set(selfie.ruleSources); this.ruleDestinations = new Set(selfie.ruleDestinations); + this.resetCache(); this.modifyTime = Date.now(); return true; });