diff --git a/Cargo.toml b/Cargo.toml index acdaa1d..acd0c95 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,27 +3,27 @@ name = "cloudinary" description = "A Rust library for the Cloudinary API" license = "MIT OR Apache-2.0" keywords = ["cloudinary", "api", "image", "video", "upload"] -version = "0.5.0" +version = "0.5.1" edition = "2021" rust-version = "1.65.0" # due to let-else [dependencies] -anyhow = "1.0.75" -chrono = "0.4.31" -itertools = "0.12.0" +anyhow = "1.0.89" +chrono = "0.4.38" +itertools = "0.13.0" mime = "0.3.17" -reqwest = { version = "0.11.22", features = ["json", "multipart", "stream"] } -serde = { version = "1.0.193", features = ["derive", "rc"] } -serde_json = "1.0.108" +reqwest = { version = "0.12.7", features = ["json", "multipart", "stream"] } +serde = { version = "1.0.210", features = ["derive", "rc"] } +serde_json = "1.0.128" sha1 = "0.10.6" -tokio = { version = "1.34.0", features = ["rt", "macros"] } -tokio-util = "0.7.10" -url = "2.4.1" +tokio = { version = "1.40.0", features = ["rt", "macros"] } +tokio-util = "0.7.12" +url = "2.5.2" [dev-dependencies] dotenv = "0.15.0" -pretty_assertions = "1.4.0" +pretty_assertions = "1.4.1" # for minimal-versions [target.'cfg(any())'.dependencies] diff --git a/src/transformation/mod.rs b/src/transformation/mod.rs index 0e0951a..42efd58 100644 --- a/src/transformation/mod.rs +++ b/src/transformation/mod.rs @@ -99,13 +99,9 @@ impl Image { Some(format) => { let file_name = self.public_id.split('/').last().unwrap().to_string(); - let new_flie_name = format!( - "{}.{}", - file_name.split('.').collect::>().pop().unwrap(), - format - ); + let new_file_name = format!("{}.{}", file_name, format); url.set_path( - path.replace(file_name.as_str(), new_flie_name.as_str()) + path.replace(file_name.as_str(), new_file_name.as_str()) .as_str(), ); } @@ -160,7 +156,7 @@ impl TryFrom for Image { let mut cloud_name: Option<&str> = None; let mut public_id_parts: Vec<(&str, Option<&str>)> = Vec::new(); - let mut public_id_teritory = false; + let mut public_id_territory = false; for (pos, s) in url.path_segments().unwrap().enumerate() { match pos { 0 => { @@ -189,14 +185,14 @@ impl TryFrom for Image { } } _ => { - if !public_id_teritory && is_version(s) { - public_id_teritory = true; - } else if !public_id_teritory && is_transformation(s) { + if !public_id_territory && is_version(s) { + public_id_territory = true; + } else if !public_id_territory && is_transformation(s) { } else if let Some((head, tail)) = s.rsplit_once('.') { - public_id_teritory = true; + public_id_territory = true; public_id_parts.push((head, Some(tail))); } else { - public_id_teritory = true; + public_id_territory = true; public_id_parts.push((s, None)); } } @@ -427,6 +423,10 @@ mod tests { assert_eq!(image.cloud_name, "test".into()); assert_eq!(image.public_id, "1.2".into()); assert_eq!(image.get_format(), Some("jpg".into())); + assert_eq!( + image.to_string(), + "https://res.cloudinary.com/test/image/upload/1.2.jpg" + ) } #[test] diff --git a/src/transformation/named_color.rs b/src/transformation/named_color.rs index 21b3164..3b9ec11 100644 --- a/src/transformation/named_color.rs +++ b/src/transformation/named_color.rs @@ -1,6 +1,6 @@ use std::fmt::Display; /// CSS named colors V4. -/// https://www.w3.org/TR/css-color-4/#named-colors +/// #[derive(Debug, Clone)] pub enum NamedColor { AliceBlue,