From 281da208f50f701c4f9c271f056c1aa67c971dde Mon Sep 17 00:00:00 2001 From: xfy Date: Tue, 9 Jun 2026 13:37:11 +0800 Subject: [PATCH] fix: remove stray space in upload filename format string --- src/api/upload.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/api/upload.rs b/src/api/upload.rs index 56e9d3d..fcd8fa4 100644 --- a/src/api/upload.rs +++ b/src/api/upload.rs @@ -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); + } +} +