mirror of
https://github.com/actix/actix-web.git
synced 2025-04-16 14:54:15 +00:00
Use /
instead of \
on Windows
This commit is contained in:
parent
a28d1d7778
commit
52e4a1c6a1
1 changed files with 3 additions and 5 deletions
|
@ -155,7 +155,7 @@ impl Directory {
|
|||
// show file url as relative to static path
|
||||
macro_rules! encode_file_url {
|
||||
($path:ident) => {
|
||||
utf8_percent_encode(&$path.to_string_lossy(), CONTROLS)
|
||||
utf8_percent_encode(&$path, CONTROLS)
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,8 @@ fn directory_listing(
|
|||
if dir.is_visible(&entry) {
|
||||
let entry = entry.unwrap();
|
||||
let p = match entry.path().strip_prefix(&dir.path) {
|
||||
Ok(p) => base.join(p),
|
||||
Ok(p) if cfg!(windows) => base.join(p).to_string_lossy().replace("\\", "/"),
|
||||
Ok(p) => base.join(p).to_string_lossy().into_owned(),
|
||||
Err(_) => continue,
|
||||
};
|
||||
|
||||
|
@ -1222,10 +1223,7 @@ mod tests {
|
|||
);
|
||||
|
||||
let bytes = test::read_body(resp).await;
|
||||
#[cfg(unix)]
|
||||
assert!(format!("{:?}", bytes).contains("/tests/test.png"));
|
||||
#[cfg(windows)]
|
||||
assert!(format!("{:?}", bytes).contains("/tests\\\\test.png"));
|
||||
}
|
||||
|
||||
#[actix_rt::test]
|
||||
|
|
Loading…
Reference in a new issue