0.6.4: always fetch icons
This commit is contained in:
parent
0a0bd98a93
commit
9e41e65c45
4 changed files with 2 additions and 54 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1786,7 +1786,7 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de"
|
|||
|
||||
[[package]]
|
||||
name = "site_icons"
|
||||
version = "0.6.3"
|
||||
version = "0.6.4"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"cached",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "site_icons"
|
||||
version = "0.6.3"
|
||||
version = "0.6.4"
|
||||
authors = ["Sam Denty <sam@samdenty.com>"]
|
||||
edition = "2018"
|
||||
license = "GPL-3.0"
|
||||
|
|
|
@ -94,37 +94,6 @@ impl IconInfo {
|
|||
}
|
||||
|
||||
_ => {
|
||||
if let Some(sizes) = &sizes {
|
||||
match &url.path().split('.').last().unwrap_or("").to_lowercase()[..] {
|
||||
"svg" => {
|
||||
return Ok(IconInfo::SVG {
|
||||
size: Some(*sizes.largest()),
|
||||
});
|
||||
}
|
||||
"png" => {
|
||||
return Ok(IconInfo::PNG {
|
||||
size: *sizes.largest(),
|
||||
});
|
||||
}
|
||||
"jpeg" | "jpg" => {
|
||||
return Ok(IconInfo::JPEG {
|
||||
size: *sizes.largest(),
|
||||
});
|
||||
}
|
||||
"ico" => {
|
||||
return Ok(IconInfo::ICO {
|
||||
sizes: sizes.clone(),
|
||||
});
|
||||
}
|
||||
"gif" => {
|
||||
return Ok(IconInfo::GIF {
|
||||
size: *sizes.largest(),
|
||||
});
|
||||
}
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
|
||||
let res = CLIENT
|
||||
.get(url)
|
||||
.headers(headers)
|
||||
|
|
21
src/lib.rs
21
src/lib.rs
|
@ -44,24 +44,3 @@ static CLIENT: Lazy<Client> = Lazy::new(|| {
|
|||
headers.insert(USER_AGENT, HeaderValue::from_str("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36").unwrap());
|
||||
Client::builder().default_headers(headers).build().unwrap()
|
||||
});
|
||||
|
||||
// #[cfg(test)]
|
||||
// mod tests {
|
||||
// use super::*;
|
||||
// #[tokio::test]
|
||||
// async fn test_icons() {
|
||||
// let mut icons = SiteIcons::new();
|
||||
// // scrape the icons from a url
|
||||
// icons.load_website("https://github.com").await.unwrap();
|
||||
|
||||
// // fetch all icons, ensuring they exist & determining size
|
||||
// let entries = icons.entries().await;
|
||||
|
||||
// // entries are sorted from highest to lowest resolution
|
||||
// for icon in &entries {
|
||||
// println!("{:?}", icon)
|
||||
// }
|
||||
|
||||
// assert_eq!(entries.len() > 0, true);
|
||||
// }
|
||||
// }
|
||||
|
|
Reference in a new issue