-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: $removeparam
#4528
base: master
Are you sure you want to change the base?
feat: $removeparam
#4528
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: we're going to apply filters one by one |
Leaving a note: regexp wrapping: |
test: add `isRemoveParam` and `isRedirectable` chore: reject on `removeparam` negation test: parsing removeparam test: removeparam test: removeparam
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this support exceptions like $removeparam=igshid,domain=instagram.com|threads.net
?
@@ -1535,6 +1554,14 @@ export default class NetworkFilter implements IFilter { | |||
options.push('badfilter'); | |||
} | |||
|
|||
if (this.isRemoveParam()) { | |||
if (this.removeparam!.length > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wont this throw if this.removeparam === undefined
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removeparam
is always string
here, as we always set string in parse time. I'll add some comments or improve the type clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this type change then?
public get removeparam(): string | undefined {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or just change it if (!this.removeparam) {
or typeof this.removeparam === 'string' && this.removeparam.length > 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Other methods like
get csp()
has a same shape. - We use an empty value for the full removal of parameters.
@@ -600,6 +600,96 @@ $csp=baz,domain=bar.com | |||
expect((filter as NetworkFilter).toString()).to.equal('||foo.com$image,redirect=foo.js'); | |||
expect(redirect).to.be.undefined; | |||
}); | |||
|
|||
context('removeparam', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add some tests for exceptions
This adds experimental
$removeparam
support for adblocker: https://github.com/gorhill/ublock/wiki/static-filter-syntax#removeparamThe suggested matching process changed by this PR is illustrated as follows:
Details
TODO