MCPcopy Create free account
hub / github.com/foxcpp/maddy / CleanDomain

Function CleanDomain

framework/address/norm.go:70–91  ·  view source on GitHub ↗

CleanDomain returns the address with the domain part converted into its canonical form. More specifically, converts the domain part of the address to U-labels, normalizes it to NFC and then case-folds it. Original value is also returned on the error.

(addr string)

Source from the content-addressed store, hash-verified

68//
69// Original value is also returned on the error.
70func CleanDomain(addr string) (string, error) {
71 if addr == "" { // Null return-path
72 return "", nil
73 }
74
75 mbox, domain, err := Split(addr)
76 if err != nil {
77 return addr, err
78 }
79
80 uDomain, err := idna.ToUnicode(domain)
81 if err != nil {
82 return addr, err
83 }
84 uDomain = strings.ToLower(norm.NFC.String(uDomain))
85
86 if domain == "" {
87 return mbox, nil
88 }
89
90 return mbox + "@" + uDomain, nil
91}
92
93// Equal reports whether addr1 and addr2 are considered to be
94// case-insensitively equivalent.

Callers 2

startDeliveryMethod · 0.92
rcptMethod · 0.92

Calls 2

SplitFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected