diff --git a/src/lib.rs b/src/lib.rs index 206abb8..b6053aa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -78,7 +78,7 @@ impl ResourcesGenerator { if let Some(ref mount_at) = resource.mount_at { let mut function_name = String::from("route"); - function_name.push_str(&mount_at.endpoint.replace("/", "_").replace(".", "_")); + function_name.push_str(&mount_at.endpoint.replace("/", "_").replace(".", "_").replace("-", "_")); routes.push_str(&format!( "#[get(\"{}\")]\nfn {}() -> Content<&'static {}> {{\n\tContent(ContentType::{}, {})\n}}\n\n", mount_at.endpoint, @@ -137,7 +137,7 @@ pub struct Resource { } pub struct ResourceMount { - pub endpoint: &'static str, + pub endpoint: String, pub content_type: &'static str } @@ -157,7 +157,7 @@ impl Downloader { create_dir_all(self.cache.as_path()).expect("failed to create cache directory"); } - let filename = url.get((url.rfind('/').expect("not a valid url")..)).expect("failed to parse filename"); + let filename = url.get((url.rfind('/').expect("not a valid url") + 1..)).expect("failed to parse filename"); let mut out_path = self.cache.clone(); out_path.push(filename);