1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-21 18:02:34 +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:
Raymond Hill 2024-09-20 08:15:31 -04:00
parent 4f181b0bc5
commit 59487b189c
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

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