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

Function Equal

framework/dns/norm.go:62–72  ·  view source on GitHub ↗

Equal reports whether domain1 and domain2 are equivalent as defined by IDNA2008 (RFC 5890). TL;DR Use this instead of strings.EqualFold to compare domains. Equivalence for malformed A-label domains is defined using regular byte-string comparison with case-folding applied.

(domain1, domain2 string)

Source from the content-addressed store, hash-verified

60// Equivalence for malformed A-label domains is defined using regular
61// byte-string comparison with case-folding applied.
62func Equal(domain1, domain2 string) bool {
63 // Short circult. If they are bit-equivalent, then they are also semantically
64 // equivalent.
65 if domain1 == domain2 {
66 return true
67 }
68
69 uDomain1, _ := ForLookup(domain1)
70 uDomain2, _ := ForLookup(domain2)
71 return uDomain1 == uDomain2
72}

Callers 3

relyOnDMARCMethod · 0.92
checkListMethod · 0.92
requireMatchingRDNSFunction · 0.92

Calls 1

ForLookupFunction · 0.70

Tested by

no test coverage detected