Crates.io | untrack |
lib.rs | untrack |
version | 0.1.5 |
source | src |
created_at | 2024-07-23 18:40:27.724899 |
updated_at | 2024-07-28 11:43:24.418727 |
description | Library to parse and remove tracking tokens from URLs contained in arbitrary text input |
homepage | https://github.com/f321x/untrack-rs |
repository | https://github.com/f321x/untrack-rs |
max_upload_size | |
id | 1313156 |
size | 31,750 |
This crate is intended to remove tracking tokens from URLs contained in any text input. The crate can either substitute the URLs in place or return a Vec of cleaned urls to a given text input.
Removing tracking tokens can improve the privacy of the user sharing the link containing the tokens and the consumer opening the shared link.
The crate currently supports Twitter, X, YouTube, Instagram, Substack and Spotify tracking tokens. The exact tokens can be found in src/parsing_params.rs
.
let input =
String::from("Twitter link: https://twitter.com/user/status/123?utm_source=test&s=1234");
let expected = vec!["https://twitter.com/user/status/123".to_string()];
assert_eq!(clean_urls_from_any_text(&input), Some(expected));
let mut input = String::from("Multiple URLs: https://twitter.com/user/status/123?s=12 and https://www.youtube.com/watch?v=abc&feature=share");
let result = replace_urls_in_place(&mut input);
assert!(result.is_some());
assert_eq!(input, "Multiple URLs: https://twitter.com/user/status/123 and https://www.youtube.com/watch?v=abc");