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
|
package inbucket
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha1"
|
"crypto/sha1"
|
||||||
"fmt"
|
"fmt"
|
||||||
"html"
|
"html"
|
||||||
"io"
|
"io"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Take "user+ext@host.com" and return "user", aka the mailbox we'll store it in
|
// Take "user+ext@host.com" and return "user", aka the mailbox we'll store it in
|
||||||
func ParseMailboxName(emailAddress string) (result string) {
|
func ParseMailboxName(emailAddress string) (result string) {
|
||||||
result = strings.ToLower(emailAddress)
|
result = strings.ToLower(emailAddress)
|
||||||
if idx := strings.Index(result, "@"); idx > -1 {
|
if idx := strings.Index(result, "@"); idx > -1 {
|
||||||
result = result[0:idx]
|
result = result[0:idx]
|
||||||
}
|
}
|
||||||
if idx := strings.Index(result, "+"); idx > -1 {
|
if idx := strings.Index(result, "+"); idx > -1 {
|
||||||
result = result[0:idx]
|
result = result[0:idx]
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
// Take a mailbox name and hash it into the directory we'll store it in
|
// Take a mailbox name and hash it into the directory we'll store it in
|
||||||
func HashMailboxName(mailbox string) string {
|
func HashMailboxName(mailbox string) string {
|
||||||
h := sha1.New()
|
h := sha1.New()
|
||||||
io.WriteString(h, mailbox)
|
io.WriteString(h, mailbox)
|
||||||
return fmt.Sprintf("%x", h.Sum(nil))
|
return fmt.Sprintf("%x", h.Sum(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextToHtml takes plain text, escapes it and tries to pretty it up for
|
// 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")
|
replacer := strings.NewReplacer("\r\n", "<br/>\n", "\r", "<br/>\n", "\n", "<br/>\n")
|
||||||
return replacer.Replace(text)
|
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\r\nbreak"), "line<br/>\nbreak")
|
||||||
assert.Equal(t, TextToHtml("line\rbreak"), "line<br/>\nbreak")
|
assert.Equal(t, TextToHtml("line\rbreak"), "line<br/>\nbreak")
|
||||||
}
|
}
|
||||||
|
|
||||||