diff --git a/composer.json b/composer.json index 92c3f21..487cd66 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "googleads/data-manager-util", "description": "Utilities and code samples for working with the Data Manager API and PHP.", "type": "library", - "version": "0.1.0", + "version": "0.2.0", "license": "Apache-2.0", "autoload": { "psr-4": { diff --git a/src/Google/Ads/DataManagerUtil/Formatter.php b/src/Google/Ads/DataManagerUtil/Formatter.php index 8a5d098..6a9e75d 100644 --- a/src/Google/Ads/DataManagerUtil/Formatter.php +++ b/src/Google/Ads/DataManagerUtil/Formatter.php @@ -59,6 +59,9 @@ public function formatEmailAddress(string $email): string // "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 = explode('+', $user)[0]; + // Removes all periods (.). $user = str_replace('.', '', $user); if (strlen($user) === 0) { diff --git a/tests/Google/Ads/DataManagerUtil/FormatterTest.php b/tests/Google/Ads/DataManagerUtil/FormatterTest.php index 7d44427..e9ed4ba 100644 --- a/tests/Google/Ads/DataManagerUtil/FormatterTest.php +++ b/tests/Google/Ads/DataManagerUtil/FormatterTest.php @@ -45,6 +45,9 @@ public static function validEmailAddressProvider(): array 'case normalized domain' => ['QuinnY@EXAMPLE.com', 'quinny@example.com'], 'periods stripped from gmail.com' => ['Jefferson.Loves.hiking@gmail.com', 'jeffersonloveshiking@gmail.com'], 'periods stripped from googlemail.com' => ['Jefferson.LOVES.Hiking@googlemail.com', 'jeffersonloveshiking@googlemail.com'], + 'plus signs not stripped from non-google' => ['user.name+NYC@Example.com', 'user.name+nyc@example.com'], + 'plus signs stripped from gmail.com' => ['Cloudy.SanFrancisco+shopping@gmail.com', 'cloudysanfrancisco@gmail.com'], + 'plus signs stripped from googlemail.com' => ['Cloudy.SanFrancisco+shopping@googlemail.com', 'cloudysanfrancisco@googlemail.com'], ]; }