mirror of https://github.com/gorhill/uBlock.git
Fix handling of fragment when applying `queryprune`
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/1415
This commit is contained in:
parent
8f91acd5b3
commit
1c37e29e0a
|
@ -4284,7 +4284,9 @@ 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 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 = [];
|
const out = [];
|
||||||
for ( const directive of directives ) {
|
for ( const directive of directives ) {
|
||||||
if ( params.size === 0 ) { break; }
|
if ( params.size === 0 ) { break; }
|
||||||
|
@ -4333,9 +4335,12 @@ FilterContainer.prototype.filterQuery = function(fctxt) {
|
||||||
fctxt.redirectURL = url.slice(0, qpos);
|
fctxt.redirectURL = url.slice(0, qpos);
|
||||||
if ( params.size !== 0 ) {
|
if ( params.size !== 0 ) {
|
||||||
fctxt.redirectURL += '?' + Array.from(params).map(a =>
|
fctxt.redirectURL += '?' + Array.from(params).map(a =>
|
||||||
`${a[0]}=${encodeURIComponent(a[1])}`
|
a[1] === '' ? a[0] : `${a[0]}=${encodeURIComponent(a[1])}`
|
||||||
).join('&');
|
).join('&');
|
||||||
}
|
}
|
||||||
|
if ( hpos !== url.length ) {
|
||||||
|
fctxt.redirectURL += url.slice(hpos);
|
||||||
|
}
|
||||||
return out;
|
return out;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue