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
16 changes: 11 additions & 5 deletions spec/src/utils/request-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ describe('ConstructorIO - Utils - Request Queue', function utilsRequestQueue() {
'test@test.com.com',
'test+100@test.com',
'test-100@test-test.io',
' test@test.io',
'test@test.com.com ',
' test.100@test.com.au ',
'text test.100@test.io text',
'test@test@test.com', // This string includes a valid email - test@test.com
],
replaceBy: '<email_omitted>',
},
Expand Down Expand Up @@ -112,7 +117,6 @@ describe('ConstructorIO - Utils - Request Queue', function utilsRequestQueue() {
'test123@.com.com',
'test()*@test.com',
'test@%*.com',
'test@test@test.com',
'test@test',
// Phone Number
'123',
Expand Down Expand Up @@ -234,8 +238,9 @@ describe('ConstructorIO - Utils - Request Queue', function utilsRequestQueue() {
expect(queue[index].url).to.equal(`https://ac.cnstrc.com/autocomplete/${replaceBy}/search?original_query=${replaceBy}&c=ciojs-2.686.3&i=c8a838d3-b7e0-48bd-92f1-81e08f84b9ee&s=5`);
});

expect(queue).to.be.an('array').length(43);
expect(store.local.get(storageKey)).to.be.an('array').length(43);
const piiCount = piiExamples.reduce((acc, curr) => acc + curr.queries.length, 0);
expect(queue).to.be.an('array').length(piiCount);
expect(store.local.get(storageKey)).to.be.an('array').length(piiCount);
helpers.triggerUnload();
});

Expand All @@ -252,8 +257,9 @@ describe('ConstructorIO - Utils - Request Queue', function utilsRequestQueue() {
expect(queue[index].url).to.equal(`https://ac.cnstrc.com/autocomplete/${query}/search?original_query=${query}&c=ciojs-2.686.3&i=c8a838d3-b7e0-48bd-92f1-81e08f84b9ee&s=5`);
});

expect(RequestQueue.get()).to.be.an('array').length(36);
expect(store.local.get(storageKey)).to.be.an('array').length(36);
const noPiiCount = notPiiExamples.length;
expect(RequestQueue.get()).to.be.an('array').length(noPiiCount);
expect(store.local.get(storageKey)).to.be.an('array').length(noPiiCount);
helpers.triggerUnload();
});

Expand Down
2 changes: 1 addition & 1 deletion src/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const purchaseEventStorageKey = '_constructorio_purchase_order_ids';

const PII_REGEX = [
{
pattern: /^[\w\-+\\.]+@([\w-]+\.)+[\w-]{2,4}$/,
pattern: /[\w\-+\\.]+@([\w-]+\.)+[\w-]{2,4}/,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing the "starts with" (^) and "ends with" ($) criteria from this pattern makes perfect conceptual sense to me.

this not only helps us match on strings with whitespace on either side of an email but also with other characters as well. We do want to prevent sending emails in tracking events regardless of whether the entire string is an email. that is what this change does. i like it

replaceBy: '<email_omitted>',
},
{
Expand Down