diff --git a/src/registry.rs b/src/registry.rs index 5252622bd..8722a3990 100644 --- a/src/registry.rs +++ b/src/registry.rs @@ -272,7 +272,11 @@ impl<'reg> Registry<'reg> { { let dir_path = dir_path.as_ref(); - let prefix_len = if dir_path.to_string_lossy().ends_with(path::MAIN_SEPARATOR) { + let prefix_len = if dir_path + .to_string_lossy() + .ends_with(|c| c == '\\' || c == '/') + // `/` will work on windows too so we still need to check + { dir_path.to_string_lossy().len() } else { dir_path.to_string_lossy().len() + 1 @@ -718,6 +722,29 @@ mod test { dir.close().unwrap(); } + + { + let dir = tempdir().unwrap(); + + let file1_path = dir.path().join("t10.hbs"); + let mut file1: File = File::create(&file1_path).unwrap(); + writeln!(file1, "