Skip to content

Commit

Permalink
fix(http): only url encode the filename, not other parts of the path
Browse files Browse the repository at this point in the history
  • Loading branch information
DevYukine committed Nov 19, 2023
1 parent 630047d commit 64d0310
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions rustfoil-lib/src/http/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ impl HttpFile {
) -> anyhow::Result<HttpFile> {
let path = local_file.path.strip_prefix(base_path)?;

let file_name = path.file_name().unwrap().to_str().unwrap();
let parent = path.parent().unwrap().to_str().unwrap();

let file_path = format!("{}/{}", parent, urlencoding::encode(file_name));

Ok(HttpFile {
url: format!(
"{}{}",
base_url,
urlencoding::encode(path.to_str().unwrap())
),
url: base_url.to_string() + file_path.as_str(),
size: local_file.size as i64,
name: local_file.name.clone(),
})
Expand Down

0 comments on commit 64d0310

Please sign in to comment.