1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2025-02-04 22:04:42 +00:00
ibis/src/utils.rs

14 lines
444 B
Rust
Raw Normal View History

use rand::{distributions::Alphanumeric, thread_rng, Rng};
use url::{ParseError, Url};
2023-11-21 15:27:18 +00:00
pub fn generate_activity_id(domain: &Url) -> Result<Url, ParseError> {
let port = domain.port().unwrap();
2023-11-15 00:32:46 +00:00
let domain = domain.domain().unwrap();
let id: String = thread_rng()
.sample_iter(&Alphanumeric)
.take(7)
.map(char::from)
.collect();
2023-11-21 15:27:18 +00:00
Url::parse(&format!("http://{}:{}/objects/{}", domain, port, id))
}