adblock 0.5.0

Native Rust module for Adblock Plus syntax (e.g. EasyList, EasyPrivacy) filter parsing and matching.
Documentation
1
2
3
4
5
6
7
8
9
10
11
use url::{Url};

fn parse_url(url: &str) -> Option<Url> {
    url.parse::<Url>()
    .ok() // convert to Option
}

pub fn get_url_host(url: &str) -> Option<String> {
    parse_url(url)
    .and_then(|p| p.host_str().map(String::from))
}