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

Function Equal

framework/address/norm.go:105–115  ·  view source on GitHub ↗

Equal reports whether addr1 and addr2 are considered to be case-insensitively equivalent. The equivalence is defined to be the conjunction of IDN label equivalence for the domain part and canonical equivalence* of the local-part converted to lower case. * IDN label equivalence is defined by RFC 58

(addr1, addr2 string)

Source from the content-addressed store, hash-verified

103// Equivalence for malformed addresses is defined using regular byte-string
104// comparison with case-folding applied.
105func Equal(addr1, addr2 string) bool {
106 // Short circuit. If they are bit-equivalent, then they are also canonically
107 // equivalent.
108 if addr1 == addr2 {
109 return true
110 }
111
112 uAddr1, _ := ForLookup(addr1)
113 uAddr2, _ := ForLookup(addr2)
114 return uAddr1 == uAddr2
115}
116
117func IsASCII(s string) bool {
118 for _, ch := range s {

Callers 1

TestEqualFunction · 0.70

Calls 1

ForLookupFunction · 0.70

Tested by 1

TestEqualFunction · 0.56