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
1 changed files with 5 additions and 4 deletions

View File

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