Skip to content

Commit cacc8f7

Browse files
committed
fix(html): use forward slashes for static file paths on Windows
1 parent 8c3e20a commit cacc8f7

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

crates/mdbook-html/src/html_handlebars/static_files.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,19 +161,23 @@ impl StaticFiles {
161161

162162
this.static_files.push(StaticFile::Additional {
163163
input_location,
164+
// Always use forward slashes for consistent hash_map keys across platforms.
164165
filename: custom_file
165166
.to_str()
166167
.with_context(|| "resource file names must be valid utf8")?
167-
.to_owned(),
168+
.replace('\\', "/"),
168169
});
169170
}
170171

171172
for input_location in theme.font_files.iter().cloned() {
172-
let filename = Path::new("fonts")
173-
.join(input_location.file_name().unwrap())
174-
.to_str()
175-
.with_context(|| "resource file names must be valid utf8")?
176-
.to_owned();
173+
let filename = format!(
174+
"fonts/{}",
175+
input_location
176+
.file_name()
177+
.unwrap()
178+
.to_str()
179+
.with_context(|| "resource file names must be valid utf8")?
180+
);
177181
this.static_files.push(StaticFile::Additional {
178182
input_location,
179183
filename,

0 commit comments

Comments
 (0)