New directory layout - DOES NOT COMPILE
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
|
Before Width: | Height: | Size: 161 B After Width: | Height: | Size: 161 B |
|
Before Width: | Height: | Size: 379 B After Width: | Height: | Size: 379 B |
|
Before Width: | Height: | Size: 407 B After Width: | Height: | Size: 407 B |
|
Before Width: | Height: | Size: 161 B After Width: | Height: | Size: 161 B |
|
Before Width: | Height: | Size: 565 B After Width: | Height: | Size: 565 B |
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
|
Before Width: | Height: | Size: 109 B After Width: | Height: | Size: 109 B |
|
Before Width: | Height: | Size: 365 B After Width: | Height: | Size: 365 B |
|
Before Width: | Height: | Size: 108 B After Width: | Height: | Size: 108 B |
|
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.7 KiB |
|
Before Width: | Height: | Size: 276 B After Width: | Height: | Size: 276 B |
@@ -1,30 +1,30 @@
|
||||
package inbucket
|
||||
|
||||
import (
|
||||
"crypto/sha1"
|
||||
"fmt"
|
||||
"html"
|
||||
"io"
|
||||
"strings"
|
||||
"crypto/sha1"
|
||||
"fmt"
|
||||
"html"
|
||||
"io"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Take "user+ext@host.com" and return "user", aka the mailbox we'll store it in
|
||||
func ParseMailboxName(emailAddress string) (result string) {
|
||||
result = strings.ToLower(emailAddress)
|
||||
if idx := strings.Index(result, "@"); idx > -1 {
|
||||
result = result[0:idx]
|
||||
}
|
||||
if idx := strings.Index(result, "+"); idx > -1 {
|
||||
result = result[0:idx]
|
||||
}
|
||||
return result
|
||||
result = strings.ToLower(emailAddress)
|
||||
if idx := strings.Index(result, "@"); idx > -1 {
|
||||
result = result[0:idx]
|
||||
}
|
||||
if idx := strings.Index(result, "+"); idx > -1 {
|
||||
result = result[0:idx]
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// Take a mailbox name and hash it into the directory we'll store it in
|
||||
func HashMailboxName(mailbox string) string {
|
||||
h := sha1.New()
|
||||
io.WriteString(h, mailbox)
|
||||
return fmt.Sprintf("%x", h.Sum(nil))
|
||||
h := sha1.New()
|
||||
io.WriteString(h, mailbox)
|
||||
return fmt.Sprintf("%x", h.Sum(nil))
|
||||
}
|
||||
|
||||
// TextToHtml takes plain text, escapes it and tries to pretty it up for
|
||||
@@ -34,4 +34,3 @@ func TextToHtml(text string) string {
|
||||
replacer := strings.NewReplacer("\r\n", "<br/>\n", "\r", "<br/>\n", "\n", "<br/>\n")
|
||||
return replacer.Replace(text)
|
||||
}
|
||||
|
||||
@@ -41,4 +41,3 @@ func TestTextToHtml(t *testing.T) {
|
||||
assert.Equal(t, TextToHtml("line\r\nbreak"), "line<br/>\nbreak")
|
||||
assert.Equal(t, TextToHtml("line\rbreak"), "line<br/>\nbreak")
|
||||
}
|
||||
|
||||