Skip to content

Commit 78f091c

Browse files
Merge pull request #12 from googleads/update-util-library-gmail
chore(format): Update formatter to handle plus signs in emails with Google domains
2 parents 856bb9e + c6a5ca1 commit 78f091c

5 files changed

Lines changed: 16 additions & 4 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

samples/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"dependencies": {
2020
"@google-ads/datamanager": "^0.1.0",
21-
"@google-ads/data-manager-util": "^0.2.0",
21+
"@google-ads/data-manager-util": "^0.3.0",
2222
"csv-parser": "^3.0.0",
2323
"yargs": "^17.7.2"
2424
},

util/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@google-ads/data-manager-util",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"description": "A utility library for the Data Manager API for Node.js.",
55
"main": "dist/src/index.js",
66
"types": "dist/src/index.d.ts",

util/src/formatter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export class UserDataFormatter {
4747
}
4848

4949
if (domain === 'gmail.com' || domain === 'googlemail.com') {
50+
username = username.split('+')[0];
5051
username = username.replace(/\./g, '');
5152
}
5253

util/test/formatter.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ describe('UserDataFormatter', () => {
2828
expect(formatter.formatEmailAddress('QuinnY@EXAMPLE.com')).to.equal(
2929
'quinny@example.com',
3030
);
31+
expect(
32+
formatter.formatEmailAddress('user.name+NYC@Example.com'),
33+
).to.equal('user.name+nyc@example.com');
3134
});
3235

3336
it('should throw an error for invalid email addresses', () => {
@@ -47,6 +50,14 @@ describe('UserDataFormatter', () => {
4750
expect(
4851
formatter.formatEmailAddress('jefferson.Loves.hiking@googlemail.com'),
4952
).to.equal('jeffersonloveshiking@googlemail.com');
53+
expect(
54+
formatter.formatEmailAddress('Cloudy.SanFrancisco+shopping@gmail.com'),
55+
).to.equal('cloudysanfrancisco@gmail.com');
56+
expect(
57+
formatter.formatEmailAddress(
58+
'Cloudy.SanFrancisco+shopping@googlemail.com',
59+
),
60+
).to.equal('cloudysanfrancisco@googlemail.com');
5061
});
5162
});
5263

0 commit comments

Comments
 (0)