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)
| 60 | // Equivalence for malformed A-label domains is defined using regular |
| 61 | // byte-string comparison with case-folding applied. |
| 62 | func 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 | } |
no test coverage detected