fix: remove stray space in upload filename format string
This commit is contained in:
parent
44c1358da5
commit
281da208f5
@ -154,7 +154,7 @@ pub async fn upload_image(
|
||||
};
|
||||
|
||||
let dir_path = format!("uploads/{}/{}/{}", year, month, day);
|
||||
let file_name = format!("{}.{ }.{}", now.format("%H%M%S"), uuid, ext);
|
||||
let file_name = format!("{}.{}.{}", now.format("%H%M%S"), uuid, ext);
|
||||
let file_path = format!("{}/{}", dir_path, file_name);
|
||||
let url_path = format!("/uploads/{}/{}/{}/{}", year, month, day, file_name);
|
||||
|
||||
@ -189,4 +189,16 @@ pub async fn upload_image(
|
||||
})))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn filename_format_no_spaces() {
|
||||
let now_str = "120000";
|
||||
let uuid = "abc-123";
|
||||
let ext = "jpg";
|
||||
let file_name = format!("{}.{}.{}", now_str, uuid, ext);
|
||||
assert!(!file_name.contains(' '), "filename should not contain spaces: got '{}'", file_name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user