MCPcopy Create free account
hub / github.com/basecamp/hey-cli / ParseTopicAddressed

Function ParseTopicAddressed

internal/htmlutil/entries.go:30–53  ·  view source on GitHub ↗

ParseTopicAddressed extracts To/CC/BCC recipients from a topic's HTML page.

(html string)

Source from the content-addressed store, hash-verified

28
29// ParseTopicAddressed extracts To/CC/BCC recipients from a topic's HTML page.
30func ParseTopicAddressed(html string) *TopicAddressed {
31 m := fullRecipientsRe.FindStringSubmatch(html)
32 if m == nil {
33 return &TopicAddressed{}
34 }
35 content := m[1]
36
37 result := &TopicAddressed{}
38 parts := ccSplitRe.Split(content, -1)
39 labels := ccSplitRe.FindAllString(content, -1)
40
41 // First part is always "to"
42 result.To = extractEmails(parts[0])
43 for i, label := range labels {
44 emails := extractEmails(parts[i+1])
45 switch label {
46 case "CC:":
47 result.CC = emails
48 case "BCC:":
49 result.BCC = emails
50 }
51 }
52 return result
53}
54
55func extractEmails(html string) []string {
56 matches := titleEmailRe.FindAllStringSubmatch(html, -1)

Callers 1

runMethod · 0.92

Calls 1

extractEmailsFunction · 0.85

Tested by

no test coverage detected