From 693907dccc4fdba4e249c109b2f2db1b10dfbb91 Mon Sep 17 00:00:00 2001 From: Marlon Baeten Date: Mon, 11 Nov 2024 13:55:19 +0100 Subject: [PATCH] Fix windows paths --- memory-serve-core/src/code.rs | 8 ++++---- memory-serve-macros/Cargo.toml | 3 +-- memory-serve/src/lib.rs | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/memory-serve-core/src/code.rs b/memory-serve-core/src/code.rs index 75fa313..d6b24e7 100644 --- a/memory-serve-core/src/code.rs +++ b/memory-serve-core/src/code.rs @@ -36,9 +36,9 @@ pub fn assets_to_code(asset_dir: &str, path: &Path, embed: bool, log: fn(&str)) let file_path = Path::new(&out_dir).join(file_name); std::fs::write(&file_path, compressed_bytes).expect("Unable to write file to out dir."); - format!("Some(include_bytes!(\"{}\"))", file_path.to_string_lossy()) + format!("Some(include_bytes!(r\"{}\"))", file_path.to_string_lossy()) } else { - format!("Some(include_bytes!(\"{}\"))", path.to_string_lossy()) + format!("Some(include_bytes!(r\"{}\"))", path.to_string_lossy()) }; let is_compressed = compressed_bytes.is_some(); @@ -46,8 +46,8 @@ pub fn assets_to_code(asset_dir: &str, path: &Path, embed: bool, log: fn(&str)) code.push_str(&format!( " memory_serve::Asset {{ - route: \"{route}\", - path: {path:?}, + route: r\"{route}\", + path: r{path:?}, content_type: \"{content_type}\", etag: \"{etag}\", bytes: {bytes}, diff --git a/memory-serve-macros/Cargo.toml b/memory-serve-macros/Cargo.toml index 8cf529c..d619765 100644 --- a/memory-serve-macros/Cargo.toml +++ b/memory-serve-macros/Cargo.toml @@ -14,5 +14,4 @@ proc-macro = true force-embed = [] [dependencies] -memory-serve-core = { path = "../memory-serve-core" } -proc-macro2 = "1.0" \ No newline at end of file +memory-serve-core = { path = "../memory-serve-core" } \ No newline at end of file diff --git a/memory-serve/src/lib.rs b/memory-serve/src/lib.rs index ed69cec..f61e7a6 100644 --- a/memory-serve/src/lib.rs +++ b/memory-serve/src/lib.rs @@ -365,7 +365,7 @@ mod tests { "text/html" ] ); - if cfg!(debug_assertions) { + if cfg!(debug_assertions) || cfg!(feature = "force-embed") { assert_eq!(etags, ["", "", "", "", "", "", ""]); } else { assert_eq!(