1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-08 12:57:57 +02:00

Fix handling of fragment when applying queryprune

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/1415
This commit is contained in:
Raymond Hill 2020-12-24 07:35:26 -05:00
parent 8f91acd5b3
commit 1c37e29e0a
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -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;
};