From 1afcf2de21d486f7152af0b56a143625b042b026 Mon Sep 17 00:00:00 2001 From: Arnaud_Cayrol Date: Wed, 4 Feb 2026 20:56:52 +0100 Subject: [PATCH] Add tests for folder name --- src/utils.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/utils.rs b/src/utils.rs index f878b98..17ba79f 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -6,6 +6,7 @@ use unicode_normalization::{char::is_combining_mark, UnicodeNormalization}; /// /// This sanitizes user input to create safe filesystem paths by: /// - Using the person name if provided and non-empty, otherwise falling back to ID +/// - Removing accents and diacritical marks /// - Converting to lowercase /// - Replacing spaces with underscores /// - Replacing unsafe characters with underscores @@ -82,4 +83,22 @@ mod tests { let result = sanitize_folder_name(Some(&long_name), "id"); assert_eq!(result.len(), 50); } + + #[test] + fn test_sanitize_folder_name_removes_accents() { + // French accents + assert_eq!(sanitize_folder_name(Some("José"), "id"), "jose"); + assert_eq!(sanitize_folder_name(Some("René"), "id"), "rene"); + assert_eq!(sanitize_folder_name(Some("François"), "id"), "francois"); + + // German umlauts + assert_eq!(sanitize_folder_name(Some("Müller"), "id"), "muller"); + assert_eq!(sanitize_folder_name(Some("Björk"), "id"), "bjork"); + + // Spanish + assert_eq!(sanitize_folder_name(Some("Peña"), "id"), "pena"); + + // Mixed accents + assert_eq!(sanitize_folder_name(Some("Élève Français"), "id"), "eleve_francais"); + } }