File tree Expand file tree Collapse file tree 2 files changed +12
-16
lines changed
Expand file tree Collapse file tree 2 files changed +12
-16
lines changed Original file line number Diff line number Diff line change @@ -254,14 +254,12 @@ def normalize_and_hash_email_address(email_address: str) -> str:
254254
255255 # Check that there are at least two segments
256256 if len (email_parts ) > 1 :
257- # Checks whether the domain of the email address is either "gmail.com"
258- # or "googlemail.com". If this regex does not match then this statement
259- # will evaluate to None.
260- if re .match (r"^(gmail|googlemail)\.com$" , email_parts [1 ]):
261- # Removes any '.' characters from the portion of the email address
262- # before the domain if the domain is gmail.com or googlemail.com.
263- email_parts [0 ] = email_parts [0 ].replace ("." , "" )
264- normalized_email = "@" .join (email_parts )
257+ # Removes any '.' and '+' characters from the portion of the email address
258+ # before the domain
259+ chars_to_remove = ".+"
260+ translation_table = str .maketrans ('' , '' , chars_to_remove )
261+ email_parts [0 ] = email_parts [0 ].translate (translation_table )
262+ normalized_email = "@" .join (email_parts )
265263
266264 return normalize_and_hash (normalized_email )
267265
Original file line number Diff line number Diff line change @@ -233,14 +233,12 @@ def normalize_and_hash_email_address(email_address):
233233
234234 # Check that there are at least two segments
235235 if len (email_parts ) > 1 :
236- # Checks whether the domain of the email address is either "gmail.com"
237- # or "googlemail.com". If this regex does not match then this statement
238- # will evaluate to None.
239- if re .match (r"^(gmail|googlemail)\.com$" , email_parts [1 ]):
240- # Removes any '.' characters from the portion of the email address
241- # before the domain if the domain is gmail.com or googlemail.com.
242- email_parts [0 ] = email_parts [0 ].replace ("." , "" )
243- normalized_email = "@" .join (email_parts )
236+ # Removes any '.' and '+' characters from the portion of the email address
237+ # before the domain
238+ chars_to_remove = ".+"
239+ translation_table = str .maketrans ('' , '' , chars_to_remove )
240+ email_parts [0 ] = email_parts [0 ].translate (translation_table )
241+ normalized_email = "@" .join (email_parts )
244242
245243 return normalize_and_hash (normalized_email )
246244
You can’t perform that action at this time.
0 commit comments