Skip to content

Commit

Permalink
Add +https directive to urlskip= option
Browse files Browse the repository at this point in the history
When present, the `+https` directive will force the protocol of the
resulting URL to be `https:`.

Related feedback:
uBlockOrigin/uBlock-issues#3206 (comment)
  • Loading branch information
gorhill committed Sep 20, 2024
1 parent 4f181b0 commit 59487b1
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/js/static-net-filtering.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 59487b1

Please sign in to comment.