1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 11:22:38 +01:00

URLSearchParams() can't be iterated as a Map()

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/760#issuecomment-720434320
This commit is contained in:
Raymond Hill 2020-11-02 07:41:21 -05:00
parent c05e78b886
commit 9c43a48445
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -3560,7 +3560,7 @@ FilterContainer.prototype.filterQuery = function(fctxt) {
const url = fctxt.url; const url = fctxt.url;
const qpos = url.indexOf('?'); const qpos = url.indexOf('?');
if ( qpos === -1 ) { return; } if ( qpos === -1 ) { return; }
const params = new self.URLSearchParams(url.slice(qpos + 1)); const params = new Map(new self.URLSearchParams(url.slice(qpos + 1)));
const out = []; const out = [];
for ( const directive of directives ) { for ( const directive of directives ) {
const modifier = directive.modifier; const modifier = directive.modifier;
@ -3583,9 +3583,10 @@ FilterContainer.prototype.filterQuery = function(fctxt) {
} }
if ( out.length === 0 ) { return; } if ( out.length === 0 ) { return; }
fctxt.redirectURL = url.slice(0, qpos); fctxt.redirectURL = url.slice(0, qpos);
const query = params.toString(); if ( params.size !== 0 ) {
if ( query !== '' ) { fctxt.redirectURL += '?' + Array.from(params).map(a =>
fctxt.redirectURL += '?' + query; `${a[0]}=${encodeURIComponent(a[1])}`
).join('&');
} }
return out; return out;
}; };