brave / brave/adblock-rust

Rewritten_url returns null

Open
#400 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2.8k
Forks
250
Avg merge
1d 16h
Merged PRs (30d)
6

Description

i am trying to make a link filter using [this list](https://github.com/DandelionSprout/adfilt/blob/master/LegitimateURLShortener.txt) but I can't seem to get the rewritten url, here is my code along with what i expect. Am i missing something to enable removeparam in the docs?

```js
import adblockRust from 'adblock-rs';
import fs from 'node:fs';
const dataPath = './data/adblock-rust-master/data/'

const debugInfo = true;
const filterSet = new adblockRust.FilterSet(debugInfo);

const shortenerFilters = fs.readFileSync(
'LegitimateURLShortener.txt',
{ encoding: 'utf-8' },
).split('\n');
filterSet.addFilters(shortenerFilters);
console.log(shortenerFilters[0])

// const easylistFilters = fs.readFileSync(
// dataPath + 'easylist.to/easylist/easylist.txt',
// { encoding: 'utf-8' },
// ).split('\n');
// filterSet.addFilters(easylistFilters);

const uboUnbreakFilters = fs.readFileSync(
dataPath + 'uBlockOrigin/unbreak.txt',
{ encoding: 'utf-8' },
).split('\n');
filterSet.addFilters(uboUnbreakFilters);

const resources = adblockRust.uBlockResources(
dataPath + 'test/fake-uBO-files/web_accessible_resources',
dataPath + 'test/fake-uBO-files/redirect-resources.js',
dataPath + 'test/fake-uBO-files/scriptlets.js'
);

const engine = new adblockRust.Engine(filterSet, true);
engine.useResources(resources);

console.log(engine.check(
'https://www.amazon.com/National-Geographic-Hobby-Rock-Tumbler/dp/B01LQCIL88/?_encoding=UTF8&pd_rd_w=a88WT&content-id=amzn1.sym.12c47663-8a7e-43d5-9c0a-9fb1870a90c3&pf_rd_p=12c47663-8a7e-43d5-9c0a-9fb1870a90c3&pf_rd_r=3BKDDFN4AJ4N5805MMKF&pd_rd_wg=JVspV&pd_rd_r=da0cab95-d366-49ed-a9a9-52f9a277bf62&ref_=pd_hp_d_atf_dealz_cs',
'https://amazon.com',
'html',
true

));
```

result:
```
! Title: ➗ Actually Legitimate URL Shortener Tool
{
matched: false,
important: false,
redirect: null,
rewritten_url: null,
exception: null,
filter: null
}
```
expected:
```
! Title: ➗ Actually Legitimate URL Shortener Tool
{
matched: True,
important: false,
redirect: null,
rewritten_url: 'https://www.amazon.com/National-Geographic-Hobby-Rock-Tumbler/dp/B01LQCIL88/?_encoding=UTF8',
exception: null,
filter: null
}
```

thank you!

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the JavaScript reproduction using FilterSet.addFilters, Engine.useResources, and Engine.check with the linked filter list. Compare the result with the expected rewritten_url and investigate how removeparam filters are parsed or exposed through the JavaScript API. Done means the reported filter produces the expected URL or the limitation is documented and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, rust
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.