1use url::Url;
2
3#[derive(Default, Clone, Debug)]
4pub struct Http {}
5impl Http {}
6pub fn get_repo_name(url_str: &str) -> Option<String> {
7 if url_str.starts_with("git@")
9 && let Some(repo_part) = url_str.split(':').next_back()
10 {
11 return repo_part.split('/').next_back().map(String::from);
12 }
13
14 let url = Url::parse(url_str).ok()?;
16 let last = url.path_segments()?.rev().find(|s| !s.is_empty());
17 last.map(String::from)
18}
19
20pub fn test_init() {
21 let _ = env_logger::builder().is_test(true).try_init();
22}