Created
November 17, 2021 14:36
-
-
Save am-on/d2af2cf3c655b69c40fdd5de5cd1f517 to your computer and use it in GitHub Desktop.
Normalize gmail email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def normalize_gmail(email: str) -> str: | |
"""Normalize Gmail address. | |
foo@gmail.com | |
f.oo@gmail.com | |
fo.o+bar@gmail.com | |
All above addresses belongs to the same gmail account. | |
Convert all above cases to address with no `.` and `+` : foo@gmail.com | |
""" | |
username = email.lower().split("@")[0] | |
username = username.replace(".", "") | |
if "+" in username: | |
username = username.split("+")[0] | |
return f"{username}@gmail.com" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment