diff --git a/crates/warpgate/src/helpers.rs b/crates/warpgate/src/helpers.rs index c1ed9ddfc..ef46d8beb 100644 --- a/crates/warpgate/src/helpers.rs +++ b/crates/warpgate/src/helpers.rs @@ -19,14 +19,14 @@ pub fn create_cache_key(url: &str, seed: Option<&str>) -> String { format!("{:x}", sha.finalize()) } -pub fn determine_cache_extension(value: &str) -> &str { +pub fn determine_cache_extension(value: &str) -> Option<&str> { for ext in [".toml", ".json", ".jsonc", ".yaml", ".yml", ".wasm", ".txt"] { if value.ends_with(ext) { - return ext; + return Some(ext); } } - "" + None } pub async fn download_from_url_to_file( diff --git a/crates/warpgate/src/host.rs b/crates/warpgate/src/host.rs index 9b381c8e7..0d3d22ac2 100644 --- a/crates/warpgate/src/host.rs +++ b/crates/warpgate/src/host.rs @@ -252,7 +252,7 @@ fn send_request( let cache_key = create_cache_key(&input.url, None); let cache_path = data.cache_dir.join("requests").join(format!( "{cache_key}{}", - determine_cache_extension(&input.url) + determine_cache_extension(&input.url).unwrap_or_default() )); // Data to collect diff --git a/crates/warpgate/src/loader.rs b/crates/warpgate/src/loader.rs index aeef62c26..a0d6a5bb1 100644 --- a/crates/warpgate/src/loader.rs +++ b/crates/warpgate/src/loader.rs @@ -1,10 +1,10 @@ use crate::client::{create_http_client_with_options, HttpOptions}; +use crate::endpoints::*; use crate::error::WarpgateError; use crate::helpers::{ - determine_cache_extension, download_from_url_to_file, move_or_unpack_download, + create_cache_key, determine_cache_extension, download_from_url_to_file, move_or_unpack_download, }; use crate::id::Id; -use crate::{create_cache_key, endpoints::*}; use once_cell::sync::OnceCell; use starbase_archive::is_supported_archive_extension; use starbase_styles::color; @@ -155,7 +155,7 @@ impl PluginLoader { id.as_str().replace(['/', '@', '.', ' '], ""), if is_latest { "-latest-" } else { "-" }, create_cache_key(url, self.seed.as_deref()), - determine_cache_extension(url), + determine_cache_extension(url).unwrap_or(".wasm"), )) }