clearurls

A Rust library that strips tracking parameters and redirects from URLs using the crowd-sourced ClearURLs rules.

Library
Cargo
v0.0.4
4 stars
LGPL-3.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
14 /100 Needs Attention
Development Activity 0
Maintenance 0
Community 12
Maturity 44
Momentum 0

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
75 /100 Good
Architecture 74
Code Quality 78
Innovation 68
Learning Curve 82

clearurls brings the widely used ClearURLs rule set to Rust, letting you remove tracking parameters, referral tags, and redirect wrappers from URLs with a single call. The crate embeds the community-maintained rules so cleaning works out of the box, and exposes a small UrlCleaner API that returns a sanitized URL string.

Designed to be lightweight and portable, the core logic works without the standard library, making it suitable for embedded and WASM targets. Optional features add file-based rule loading and integration with linkify and markdown-it for cleaning links found inside free-form or Markdown text.

What You Get

  • A simple UrlCleaner API that returns a cleaned URL string
  • The full ClearURLs rule set embedded for offline, zero-config use
  • no_std compatibility so the core works on embedded and WASM targets
  • Optional file-based rule loading behind the std feature
  • Optional linkify and markdown-it integration to clean links inside text

Common Use Cases

  • Removing utm_* and other tracking parameters before storing or sharing URLs
  • Sanitizing links submitted by users in a forum, chat, or feed reader
  • Unwrapping redirect and referral URLs to recover the real destination

Under The Hood

Architecture - The public surface (src/lib.rs) is a UrlCleaner built from embedded or file-loaded rules; src/rules.rs deserializes the ClearURLs data.minify.json provider definitions into compiled regex matchers, and cleaning applies each matching provider’s rules to strip query parameters and unwrap redirects on a parsed url::Url. Custom deserialization helpers in src/deserialize_utils.rs adapt the JSON rule schema.

Tech Stack - Pure Rust (edition 2021, MSRV 1.65) built on serde/serde_json for rule parsing, regex for provider and parameter matching, url and percent-encoding for URL handling — all configured with default-features off so the crate stays no_std-capable. Optional linkify and markdown-it dependencies gate the text-integration features.

Code Quality - The tests/ directory holds focused suites for single-URL cleaning, linkify, and markdown integration, with cases borrowed from established URL-cleaning projects, giving reasonable behavioral coverage for a small crate. A clippy.toml signals lint discipline and the code is organized into small, single-responsibility modules.

API Design - Getting started is a two-line path: UrlCleaner::from_embedded_rules() then clear_single_url_str(...), both returning Result for explicit error handling. Feature flags keep the default build lean while letting advanced users opt into std file loading or in-text link cleaning, a clean and discoverable API for a narrow, well-scoped problem.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers