8000 Rewritten_url returns null · Issue #400 · brave/adblock-rust · GitHub
[go: up one dir, main page]

Skip to content

Rewritten_url returns null #400

Open

Description

@toxin-x

i am trying to make a link filter using this list 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?

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!

Activity

  1. antonok-edm commented on Nov 7, 2024

    @antonok-edm
    Collaborator

    @toxin-x you're using 'html' as the request type, which isn't valid. You can find the full list of request types here. I assume you want to use 'document'; When I do so, I get the following:

    {
      matched: false,
      important: false,
      redirect: null,
      rewritten_url: 'https://www.amazon.com/National-Geographic-Hobby-Rock-Tumbler/dp/B01LQCIL88/?_encoding=UTF8&pd_rd_w=a88WT&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',
      exception: null,
      filter: null
    }

    Does that look how you'd expect?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0