11 unstable releases (3 breaking)
0.7.1 | Feb 14, 2024 |
---|---|
0.7.0 | Feb 9, 2024 |
0.6.4 | Nov 8, 2023 |
0.5.2 | Oct 16, 2022 |
0.4.0 | Feb 18, 2022 |
#266 in Configuration
17KB
337 lines
clearurl
This is a Rust implementation of the ClearURL lib.
Features
- Declarative configuration
- Full regexp support
- 302 redirect support
- Batch apply configuration for sub domains
- Post hook for rewriting URL
Usage
- Library
# Cargo.toml
clearurl = { version = "0.6", features = ["hooks"] }
use clearurl::URLCleaner;
#[tokio::main]
async fn main() {
std::fs::write("rules.toml", r#"
["b23.tv"]
redirect = true
["bilibili.com"]
sub = ["www", "live", "m"]
ban = [
"-Arouter",
"bbid",
"buvid",
"callback",
"from.*",
"is_story_h5",
"mid",
"msource",
"plat_id",
"refer_from",
"seid",
"share.*",
"spm_id.*",
"timestamp",
"ts",
"unique_k",
"up_id",
"vd_source",
]
post_hooks = [ "bv_to_av" ]
"#).unwrap();
let cleaner = URLCleaner::from_file("./rules.toml").unwrap();
let url = cleaner.clear("https://b23.tv/Cj2HC2K").await.unwrap();
assert_eq!(
url.as_str(),
"https://www.bilibili.com/video/av746592874/?p=1"
);
}
Dependencies
~8–21MB
~297K SLoC