diff --git a/src/js/static-net-filtering.js b/src/js/static-net-filtering.js index c38159bbb..335f52f15 100644 --- a/src/js/static-net-filtering.js +++ b/src/js/static-net-filtering.js @@ -4284,7 +4284,9 @@ FilterContainer.prototype.filterQuery = function(fctxt) { const url = fctxt.url; const qpos = url.indexOf('?'); if ( qpos === -1 ) { return; } - const params = new Map(new self.URLSearchParams(url.slice(qpos + 1))); + let hpos = url.indexOf('#', qpos + 1); + if ( hpos === -1 ) { hpos = url.length; } + const params = new Map(new self.URLSearchParams(url.slice(qpos + 1, hpos))); const out = []; for ( const directive of directives ) { if ( params.size === 0 ) { break; } @@ -4333,9 +4335,12 @@ FilterContainer.prototype.filterQuery = function(fctxt) { fctxt.redirectURL = url.slice(0, qpos); if ( params.size !== 0 ) { fctxt.redirectURL += '?' + Array.from(params).map(a => - `${a[0]}=${encodeURIComponent(a[1])}` + a[1] === '' ? a[0] : `${a[0]}=${encodeURIComponent(a[1])}` ).join('&'); } + if ( hpos !== url.length ) { + fctxt.redirectURL += url.slice(hpos); + } return out; };