email-validate-hs icon indicating copy to clipboard operation
email-validate-hs copied to clipboard

Use CaseInsensitive for domain part to follow RFC

Open albertov opened this issue 5 years ago • 3 comments

According to RFC 1035, section 3.1:

Name servers and resolvers must compare [domains] in a case-insensitive manner

So I believe the Eq and Ord instances of EmailAddress should take it into account. This PR implements it in a API preserving way which didn't need tweaking any tests by using Data.CaseInsensitive.CI to store the domain part- A domainPartOriginal is provided to extract it in the original case in which it was parsed. Perhaps, fort better backwards compatibility, it should be the other way around? (ie: provide a domainPartFoldedCase to extract it folded and leave domainPart returning the original case)

albertov avatar Oct 03 '19 15:10 albertov

I think it makes sense for the domain part but it’s going to be a breaking change to do this so would need to be in a major version update. The local part should not be case-insensitive as the interpretation is meant to be entirely up to the destination server (which could allow case-sensitive emails, although that would be unusual!)

Porges avatar Oct 10 '19 20:10 Porges

Indeed! The local part change slipped in, it’s something we finally decided to do internally and wasn’t intended to be proposed upstream. I’ll clean that up and bump version tomorrow

albertov avatar Oct 10 '19 20:10 albertov

ping

ddssff avatar Jan 21 '24 19:01 ddssff