1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-04 01:59:38 +02: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 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;
};