Add support for <user>.fanbox.cc urls

This commit is contained in:
2022-06-24 04:58:23 +00:00
committed by GitHub
parent fc1a44e55a
commit 0da51a4ddd

View File

@@ -9,6 +9,8 @@ lazy_static! {
static ref RE: Regex = Regex::new("^(https?://)?(www\\.)?pixiv\\.net/artworks/(?P<id>\\d+)").unwrap();
#[doc(hidden)]
static ref RE2: Regex = Regex::new("^(https?://)?(www\\.)?fanbox\\.cc/@(?P<creator>[^/]+)/posts/(?P<id>\\d+)").unwrap();
#[doc(hidden)]
static ref RE3: Regex = Regex::new("^(https?://)?(?P<creator>[^./]+)\\.fanbox\\.cc/posts/(?P<id>\\d+)").unwrap();
}
#[derive(Clone, Debug)]
@@ -77,6 +79,21 @@ impl PixivID {
},
None => {}
}
match RE3.captures(s) {
Some(re) => match re.name("creator") {
Some(creator) => match re.name("id") {
Some(id) => match id.as_str().parse::<u64>() {
Ok(id) => {
return Some(Self::FanboxPost(FanboxPostID::new(creator.as_str(), id)));
}
Err(_) => {}
},
None => {}
},
None => {}
},
None => {}
}
None
}