1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 18:17:03 +00:00

New directory layout - DOES NOT COMPILE

This commit is contained in:
James Hillyerd
2012-10-20 16:40:25 -07:00
parent 2b3491fc87
commit 3dd0206b48
35 changed files with 16 additions and 18 deletions

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 161 B

After

Width:  |  Height:  |  Size: 161 B

View File

Before

Width:  |  Height:  |  Size: 379 B

After

Width:  |  Height:  |  Size: 379 B

View File

Before

Width:  |  Height:  |  Size: 407 B

After

Width:  |  Height:  |  Size: 407 B

View File

Before

Width:  |  Height:  |  Size: 161 B

After

Width:  |  Height:  |  Size: 161 B

View File

Before

Width:  |  Height:  |  Size: 565 B

After

Width:  |  Height:  |  Size: 565 B

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 109 B

After

Width:  |  Height:  |  Size: 109 B

View File

Before

Width:  |  Height:  |  Size: 365 B

After

Width:  |  Height:  |  Size: 365 B

View File

Before

Width:  |  Height:  |  Size: 108 B

After

Width:  |  Height:  |  Size: 108 B

View File

Before

Width:  |  Height:  |  Size: 8.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

Before

Width:  |  Height:  |  Size: 276 B

After

Width:  |  Height:  |  Size: 276 B

View File

@@ -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)
} }

View File

@@ -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")
} }