Skip to content

Commit

Permalink
Fix bug in normalize_and_hash_email_address function of remarketing e…
Browse files Browse the repository at this point in the history
…xamples.
  • Loading branch information
arnau126 committed Feb 25, 2023
1 parent 15d3efa commit 3412847
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
21 changes: 10 additions & 11 deletions examples/remarketing/upload_conversion_enhancement.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,18 +172,17 @@ def normalize_and_hash_email_address(email_address):
"""
normalized_email = email_address.lower()
email_parts = normalized_email.split("@")
# Checks whether the domain of the email address is either "gmail.com"
# or "googlemail.com". If this regex does not match then this statement
# will evaluate to None.
is_gmail = re.match(r"^(gmail|googlemail)\.com$", email_parts[1])

# Check that there are at least two segments and the second segment
# matches the above regex expression validating the email domain name.
if len(email_parts) > 1 and is_gmail:
# Removes any '.' characters from the portion of the email address
# before the domain if the domain is gmail.com or googlemail.com.
email_parts[0] = email_parts[0].replace(".", "")
normalized_email = "@".join(email_parts)
# Check that there are at least two segments
if len(email_parts) > 1:
# Checks whether the domain of the email address is either "gmail.com"
# or "googlemail.com". If this regex does not match then this statement
# will evaluate to None.
if re.match(r"^(gmail|googlemail)\.com$", email_parts[1]):
# Removes any '.' characters from the portion of the email address
# before the domain if the domain is gmail.com or googlemail.com.
email_parts[0] = email_parts[0].replace(".", "")
normalized_email = "@".join(email_parts)

return normalize_and_hash(normalized_email)

Expand Down
23 changes: 11 additions & 12 deletions examples/remarketing/upload_conversion_with_identifiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,17 @@ def normalize_and_hash_email_address(email_address):
"""
normalized_email = email_address.lower()
email_parts = normalized_email.split("@")
# Checks whether the domain of the email address is either "gmail.com"
# or "googlemail.com". If this regex does not match then this statement
# will evaluate to None.
is_gmail = re.match(r"^(gmail|googlemail)\.com$", email_parts[1])

# Check that there are at least two segments and the second segment
# matches the above regex expression validating the email domain name.
if len(email_parts) > 1 and is_gmail:
# Removes any '.' characters from the portion of the email address
# before the domain if the domain is gmail.com or googlemail.com.
email_parts[0] = email_parts[0].replace(".", "")
normalized_email = "@".join(email_parts)

# Check that there are at least two segments
if len(email_parts) > 1:
# Checks whether the domain of the email address is either "gmail.com"
# or "googlemail.com". If this regex does not match then this statement
# will evaluate to None.
if re.match(r"^(gmail|googlemail)\.com$", email_parts[1]):
# Removes any '.' characters from the portion of the email address
# before the domain if the domain is gmail.com or googlemail.com.
email_parts[0] = email_parts[0].replace(".", "")
normalized_email = "@".join(email_parts)

return normalize_and_hash(normalized_email)

Expand Down

0 comments on commit 3412847

Please sign in to comment.