Commit
+5 -3 +/-1 browse
1 | diff --git a/maitred/src/rewrite.rs b/maitred/src/rewrite.rs |
2 | index 4b76dac..a455288 100644 |
3 | --- a/maitred/src/rewrite.rs |
4 | +++ b/maitred/src/rewrite.rs |
5 | @@ -6,7 +6,7 @@ pub struct Rewrite<'a>(pub &'a mut Vec<u8>); |
6 | impl<'a> Rewrite<'a> { |
7 | /// Prepend a header to the message body |
8 | pub fn with_header(&mut self, key: &str, value: &str) { |
9 | - let header: Vec<u8> = format!("{}: {}", key, value).bytes().collect(); |
10 | + let header: Vec<u8> = format!("{}: {}\n", key, value.trim_end()).bytes().collect(); |
11 | self.0.splice(0..0, header); |
12 | } |
13 | |
14 | @@ -21,8 +21,7 @@ impl<'a> Rewrite<'a> { |
15 | mod test { |
16 | use super::*; |
17 | |
18 | - const TEST_EMAIL: &str = r#" |
19 | - Date: Mon, 2 Sep 2024 00:17:18 +0200 |
20 | + const TEST_EMAIL: &str = r#"Date: Mon, 2 Sep 2024 00:17:18 +0200 |
21 | From: kevin <kevin@ayllu-dev.local> |
22 | To: hello@example.org |
23 | Subject: Fuu |
24 | @@ -42,5 +41,8 @@ Hello World |
25 | let message = rewrite.message().unwrap(); |
26 | let value = message.header("a").unwrap(); |
27 | assert!(value.as_text().unwrap() == "b"); |
28 | + let message_str = String::from_utf8(message.raw_message().to_vec()).unwrap(); |
29 | + assert!(message_str.split("\n").next().unwrap() == "a: b"); |
30 | + assert!(message_str.split("\n").nth(1).unwrap() == "Date: Mon, 2 Sep 2024 00:17:18 +0200"); |
31 | } |
32 | } |