url-sanitize-core 2.0.2

Pure-Rust library for removing tracking parameters and unwrapping tracking redirects.
Documentation

url-sanitize-core

Pure-Rust implementation for removing tracking parameters and unwrapping tracking redirects according to the url-sanitize behavioral spec.

Engine only — no embedded catalog. For a ready-to-use binary with the merged ClearURLs, AdGuard, Brave, and Firefox catalog baked in, see the url-sanitize crate.

use url_sanitize_core::{Catalog, SanitizerOptions};

let json = std::fs::read_to_string("catalog/catalog.json")?;
let catalog = Catalog::from_json(&json)?;
let sanitizer = catalog.compile(SanitizerOptions::default());
let result = sanitizer.sanitize("https://example.com/?utm_source=x");
println!("{}", serde_json::to_string(&result)?);

Conformance with the TypeScript engine is verified by the shared corpus in conformance/.