mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-05 18:32:30 +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 {
|
||||
let urlout;
|
||||
for ( const step of steps ) {
|
||||
if ( step.startsWith('?') === false ) { return; }
|
||||
urlout = (new URL(urlin)).searchParams.get(step.slice(1));
|
||||
if ( urlout === null ) { return; }
|
||||
if ( urlout.includes(' ') ) {
|
||||
urlout = urlout.replace(/ /g, '%20');
|
||||
// Extract from URL parameter
|
||||
if ( step.startsWith('?') ) {
|
||||
urlout = (new URL(urlin)).searchParams.get(step.slice(1));
|
||||
if ( urlout === null ) { return; }
|
||||
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);
|
||||
return urlout;
|
||||
|
Loading…
Reference in New Issue
Block a user