Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion data-manager-util/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ plugins {

group = 'com.google.api-ads'
description = 'Utilities for working with the Data Manager API'
version = '0.2.0'
version = '0.3.0'

sourceCompatibility = 1.8
targetCompatibility = 1.8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ public String formatEmailAddress(String emailAddress) {
// "Create variations of your email address" at:
// https://support.google.com/a/users/answer/9282734

// Removes plus sign (+) and all characters that follow it.
int plusIndex = username.indexOf('+');
if (plusIndex != -1) {
username = username.substring(0, plusIndex);
}

// Removes all periods (.).
username = PERIOD_PATTERN.matcher(username).replaceAll("");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ public void testFormatEmailAddress_validInputs() {
"Case should be normalized in domain",
"quinny@example.com",
formatter.formatEmailAddress("QuinnY@EXAMPLE.com"));
assertEquals(
"Plus sign and everything after should not be stripped from non google emails",
"user.name+nyc@example.com",
formatter.formatEmailAddress("user.name+NYC@Example.com"));
}

@Test
Expand Down Expand Up @@ -69,6 +73,14 @@ public void testFormatEmailAddress_gmailVariations() {
assertEquals(
"jeffersonloveshiking@googlemail.com",
formatter.formatEmailAddress("j.e.f..ferson.Loves.hiking@googlemail.com"));
assertEquals(
"Plus sign and everything after should be stripped from gmail.com address",
"cloudysanfrancisco@gmail.com",
formatter.formatEmailAddress("Cloudy.SanFrancisco+shopping@gmail.com"));
assertEquals(
"Plus sign and everything after should be stripped from googlemail.com address",
"cloudysanfrancisco@googlemail.com",
formatter.formatEmailAddress("Cloudy.SanFrancisco+shopping@googlemail.com"));
}

@Test
Expand Down