Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/theawiteb/domain_changer
Rust library that helps you change the domain of the link to another domain 🦀🔐
https://github.com/theawiteb/domain_changer
domain domain-changer rust
Last synced: 19 days ago
JSON representation
Rust library that helps you change the domain of the link to another domain 🦀🔐
- Host: GitHub
- URL: https://github.com/theawiteb/domain_changer
- Owner: TheAwiteb
- License: agpl-3.0
- Created: 2022-03-20T18:28:08.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T03:29:56.000Z (over 1 year ago)
- Last Synced: 2024-10-11T01:50:13.065Z (about 1 month ago)
- Topics: domain, domain-changer, rust
- Language: Rust
- Homepage: https://docs.rs/domain_changer
- Size: 82 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# domain_changer
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
```rust
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)
```rust
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
```rust
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
```rust
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``` |## License
The [GNU Affero General Public](https://www.gnu.org/licenses/agpl-3.0.en.html) 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.