diff options
| author | Teddy Wing | 2016-04-18 03:31:50 -0400 |
|---|---|---|
| committer | Teddy Wing | 2016-04-18 03:31:50 -0400 |
| commit | e6b919bd86f4f3a07aae8625b2d4c53d34cfaae3 (patch) | |
| tree | a63e13a63d262c549c7abd8274d2115c24d7fbeb /src | |
| parent | fc05eb9e2f111642dbec093218b7184f25740b90 (diff) | |
| download | mutt-alias-auto-add-e6b919bd86f4f3a07aae8625b2d4c53d34cfaae3.tar.bz2 | |
Alias#to_string: Don't format `name` if it's empty
When we get a "From: " address that doesn't contain a name, the
resulting `Alias` object created by `Alias::new` will have an empty
name.
When `to_string` is called on these kinds of objects, an extra space
appears between the alias and the email address because of how the
format string is constructed.
This caused a test failure for the `new_alias_with_only_email` test
method in fc05eb9e2f111642dbec093218b7184f25740b90. Our change here
fixes and passes this test.
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 27b3e48..49c30d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,7 +41,11 @@ impl Alias { } fn to_string(&self) -> String { - format!("alias {} {} {}", self.alias, self.name, self.email) + if self.name.is_empty() { + format!("alias {} {}", self.alias, self.email) + } else { + format!("alias {} {} {}", self.alias, self.name, self.email) + } } } |
