mirror of https://github.com/fafhrd91/actix-web
Use `/` instead of `\` on Windows
This commit is contained in:
parent
a28d1d7778
commit
52e4a1c6a1
|
@ -155,7 +155,7 @@ impl Directory {
|
||||||
// show file url as relative to static path
|
// show file url as relative to static path
|
||||||
macro_rules! encode_file_url {
|
macro_rules! encode_file_url {
|
||||||
($path:ident) => {
|
($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) {
|
if dir.is_visible(&entry) {
|
||||||
let entry = entry.unwrap();
|
let entry = entry.unwrap();
|
||||||
let p = match entry.path().strip_prefix(&dir.path) {
|
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,
|
Err(_) => continue,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1222,10 +1223,7 @@ mod tests {
|
||||||
);
|
);
|
||||||
|
|
||||||
let bytes = test::read_body(resp).await;
|
let bytes = test::read_body(resp).await;
|
||||||
#[cfg(unix)]
|
|
||||||
assert!(format!("{:?}", bytes).contains("/tests/test.png"));
|
assert!(format!("{:?}", bytes).contains("/tests/test.png"));
|
||||||
#[cfg(windows)]
|
|
||||||
assert!(format!("{:?}", bytes).contains("/tests\\\\test.png"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
|
|
Loading…
Reference in New Issue