#domain #privacy #parse-url #changer #string-parser #deserialize-json

domain_changer

Rust library that helps you change the domain of the link to another domain

5 releases

0.1.4 Apr 14, 2022
0.1.3 Mar 24, 2022
0.1.2 Mar 24, 2022
0.1.1 Mar 22, 2022
0.1.0 Mar 20, 2022

#983 in Encoding

AGPL-3.0-only

30KB
218 lines

domain_changer

Wagmi

Rust report

Rust library that helps you to change the domain of the link to another domain, the library helps with privacy. It can be used to change the domain of sites that do not care about privacy to another that does.

Examples

Parse String

Parse the string and convert the old urls to new one

Note: You can change the domains as you want

use domain_changer::parse_string;
use domain_changer::types::Config;

let text: String = "Wellcome to my youtube channel: https://www.youtube.com/channel/UCeRbJsc8cl7xBwT3jIxaAdg And my twitter is: twitter.com/Awiteb".to_string();
let config: Config = Config::default();
assert_eq!(parse_string(&config, text),
           "Wellcome to my youtube channel: https://piped.kavin.rocks/channel/UCeRbJsc8cl7xBwT3jIxaAdg And my twitter is: https://nitter.net/Awiteb".to_string()
);

Extract Domains

You can extract domains from string if any (Just the domain you add it to config)

use domain_changer::extract_old_domains;
use domain_changer::types::{Config, Domain};

let config: Config = Config::default();
let text: String = String::from(
    "Hi i hate youtube.com and https://twitter.com what about you?"
);
assert_eq!(
    extract_old_domains(&config, text),
    vec![
        &Domain::try_from(("https://youtube.com/", "https://piped.kavin.rocks/")).unwrap(),
        &Domain::try_from(("https://twitter.com/", "https://nitter.net/")).unwrap()
    ]
);

Serialize and Deserialize (json feature)

Serialize and deserialize from/to json in Domain struct and Config

Note: Need json feature

Domain

use domain_changer::types::{Domain, ToFromJson};

let domain: Domain = Domain::try_from(("https://twitter.com/", "https://nitter.net/")).unwrap();
assert_eq!(domain.to_json().unwrap(), "{\"old\":\"https://twitter.com/\",\"new\":\"https://nitter.net/\"}");
assert_eq!(Domain::from_json("{\"old\":\"https://twitter.com/\",\"new\":\"https://nitter.net/\"}").unwrap(), domain);
assert!(Domain::from_json("{\"old\":\"twitter.com/\",\"new\":\"nitter.net/\"}").is_err());

Config

use domain_changer::types::{Config, Domain, ToFromJson};

let config: Config = Config::new(vec![Domain::try_from(("https://twitter.com/", "https://nitter.net/")).unwrap()]);
assert_eq!(
    config.to_json().unwrap(),
    "{\"domains\":[{\"old\":\"https://twitter.com/\",\"new\":\"https://nitter.net/\"}]}".to_string()
);

assert_eq!(
    Config::from_json("{\"domains\":[{\"old\":\"https://twitter.com/\",\"new\":\"https://nitter.net/\"}]}").unwrap(),
    config
);

Donating

Currency Address
Binance BNB BEP20 0xD89c146B03B72191be91064D313610981dCAF6d4
USD Coin USDC BEP20 0xD89c146B03B72191be91064D313610981dCAF6d4
Bitcoin BTC bc1q0ltmqmsc4qs740ssyf9k9jq99nwxtqu8aupmdj
Bitcoin Cash BCH qrpm6zyte3d4z2u9r24l04m3havc2wd9vgqlz8sjgr

Contributors

License

The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.

Dependencies

~2–3.5MB
~58K SLoC