You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hydrus-utils/src/utils/urls.rs

20 lines
362 B
Rust

use lazy_regex::regex;
pub enum UrlType {
Reddit,
Other,
}
pub fn find_url_type(url: &str) -> UrlType {
if is_reddit_url(url) {
UrlType::Reddit
} else {
UrlType::Other
}
}
fn is_reddit_url(url: &str) -> bool {
let r = regex!(r#"^http(s)?://(www\.)?(reddit\.com|redd\.it|reddit\.app\.link).*$"#i);
r.is_match(url)
}