aboutsummaryrefslogtreecommitdiff
path: root/lib/address.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/address.go')
-rw-r--r--lib/address.go40
1 files changed, 0 insertions, 40 deletions
diff --git a/lib/address.go b/lib/address.go
deleted file mode 100644
index b557195..0000000
--- a/lib/address.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package lib
-
-import (
- "bytes"
- "fmt"
- "regexp"
- "strings"
-
- "github.com/emersion/go-imap"
-)
-
-var (
- atom *regexp.Regexp = regexp.MustCompile("^[a-z0-9!#$%7'*+-/=?^_`{}|~ ]+$")
-)
-
-func FormatAddresses(addrs []*imap.Address) string {
- val := bytes.Buffer{}
- for i, addr := range addrs {
- val.WriteString(FormatAddress(addr))
- if i != len(addrs)-1 {
- val.WriteString(", ")
- }
- }
- return val.String()
-}
-
-func FormatAddress(addr *imap.Address) string {
- if addr.PersonalName != "" {
- if atom.MatchString(addr.PersonalName) {
- return fmt.Sprintf("%s <%s@%s>",
- addr.PersonalName, addr.MailboxName, addr.HostName)
- } else {
- return fmt.Sprintf("\"%s\" <%s@%s>",
- strings.ReplaceAll(addr.PersonalName, "\"", "'"),
- addr.MailboxName, addr.HostName)
- }
- } else {
- return fmt.Sprintf("<%s@%s>", addr.MailboxName, addr.HostName)
- }
-}