Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions google/ads/datamanager_util/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ def format_email_address(self, email: str) -> str:
# "Create variations of your email address" at:
# https://support.google.com/a/users/answer/9282734

# Removes plus sign (+) and all characters that follow it.
user = user.split("+")[0]
Comment thread
jradcliff marked this conversation as resolved.

# Removes all periods (.).
user = re.sub("\\.", "", user)
if len(user) == 0:
Expand Down
18 changes: 18 additions & 0 deletions tests/formatter_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ def test_format_email_address_valid_inputs(self):
"Periods should be stripped from googlemail.com address",
)

self.assertEqual(
Comment thread
jradcliff marked this conversation as resolved.
"cloudysanfrancisco@googlemail.com",
self.formatter.format_email_address("Cloudy.SanFrancisco+shopping@googlemail.com"),
"Plus sign and everything after should be stripped from googlemail.com address",
)

self.assertEqual(
"cloudysanfrancisco@gmail.com",
self.formatter.format_email_address("Cloudy.SanFrancisco+shopping@gmail.com"),
"Plus sign and everything after should be stripped from gmail.com address",
)

self.assertEqual(
"user.name+nyc@example.com",
self.formatter.format_email_address("user.name+NYC@Example.com"),
"Plus sign and everything after should not be stripped from non google emails",
)

def test_format_email_address_invalid_inputs(self):
with self.assertRaises(ValueError):
self.formatter.format_email_address(None)
Expand Down