Normalizing e-mail addresses in Go.
- remove leading and trailing whitespaces
- convert to lowercase
- remove dots from email's username
- remove the part after '+' symbol of the email's username
Because some people use the same email with aliases to abuse your services' free tier.
In Gmail, the email abanoub@gmail.com is the same email as abanoub+1@gmail.com and it is the same email as abanou.b@gmail.com.
I like to store the user written email in the database alongside the normalized email, and check the free tier validation against the normalized emails column in the database table.
| normalized_email | |
|---|---|
abanoub+4@gmail.com |
abanoub@gmail.com |
a.shraf@gmail.com |
ashraf@gmail.com |