mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-16 15:33:38 +01:00
Add +https
directive to urlskip=
option
When present, the `+https` directive will force the protocol of the resulting URL to be `https:`. Related feedback: https://github.com/uBlockOrigin/uBlock-issues/issues/3206#issuecomment-2363392357
This commit is contained in:
parent
4f181b0bc5
commit
59487b189c
@ -5424,13 +5424,25 @@ function urlSkip(urlin, steps) {
|
|||||||
try {
|
try {
|
||||||
let urlout;
|
let urlout;
|
||||||
for ( const step of steps ) {
|
for ( const step of steps ) {
|
||||||
if ( step.startsWith('?') === false ) { return; }
|
// Extract from URL parameter
|
||||||
urlout = (new URL(urlin)).searchParams.get(step.slice(1));
|
if ( step.startsWith('?') ) {
|
||||||
if ( urlout === null ) { return; }
|
urlout = (new URL(urlin)).searchParams.get(step.slice(1));
|
||||||
if ( urlout.includes(' ') ) {
|
if ( urlout === null ) { return; }
|
||||||
urlout = urlout.replace(/ /g, '%20');
|
if ( urlout.includes(' ') ) {
|
||||||
|
urlout = urlout.replace(/ /g, '%20');
|
||||||
|
}
|
||||||
|
urlin = urlout;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
urlin = urlout;
|
// Enforce https
|
||||||
|
if ( step === '+https' ) {
|
||||||
|
const s = urlin.replace(/^https?:\/\//, '');
|
||||||
|
if ( /^[\w-]:\/\//.test(s) ) { return; }
|
||||||
|
urlin = urlout = `https://${s}`;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Unknown directive
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
void new URL(urlout);
|
void new URL(urlout);
|
||||||
return urlout;
|
return urlout;
|
||||||
|
Loading…
Reference in New Issue
Block a user