diff --git a/imessage-database/src/tables/attachment.rs b/imessage-database/src/tables/attachment.rs index 71da5c4a..fd8e4ec0 100644 --- a/imessage-database/src/tables/attachment.rs +++ b/imessage-database/src/tables/attachment.rs @@ -251,7 +251,7 @@ impl Attachment { /// Generate a MacOS path for an attachment fn gen_macos_attachment(path: &str) -> String { if path.starts_with('~') { - return path.replace('~', &home()); + return path.replacen('~', &home(), 1); } path.to_string() } @@ -390,6 +390,18 @@ mod tests { ); } + #[test] + fn can_get_resolved_path_macos_raw_tilde() { + let db_path = PathBuf::from("fake_root"); + let mut attachment = sample_attachment(); + attachment.filename = Some("~/a/b/c~d.png".to_string()); + + assert!(attachment + .resolved_attachment_path(&Platform::MacOS, &db_path) + .unwrap() + .ends_with("c~d.png")); + } + #[test] fn can_get_resolved_path_ios() { let db_path = PathBuf::from("fake_root");