Giter Site home page Giter Site logo

urlmatch's Introduction

URL matcher lib

This is a small and fast C library duplicating the URL matching functionality of Opera. You might use it to implement ad blocking or similar.

Given a list of patterns, such as

*facebook.com/*
http*google-analytics.*
http://foo.bat/this-annoying-image.jpeg

you can then match any connection attempt against the whole list, getting a yes/no answer back.

Motivation

One of the main components of Opera, the filtering system, supported white- and blacklists with wildcards. It was usable for more than just blocking ads, though it handled those well too.

This is one such function that should never be relegated to Javascript (like Adblock browser extensions do). The average page makes close to a hundred connections, the list is traversed on each connection attempt, and common lists reach a few thousand entries.

Turns out there wasn’t any existing standalone pattern matching library. Regex is too slow (or in glibc’s case, taking gigabytes of RAM), and wildcard functionality is essential.

A simple function (like those you can find dozens of in the web) is included for benchmark comparison purposes. Currently this library is ~5x faster vs the simple function. This is not quite fast enough, so future optimizations will be coming.

urlmatch's People

Contributors

clbr avatar

Watchers

Tuo Jung avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.