Skip to content

Commit

Permalink
fix: email multiple at
Browse files Browse the repository at this point in the history
  • Loading branch information
abelkhay committed Jul 27, 2023
1 parent 45f688a commit 24ca20b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/transformer/fields/contact/clean-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@ const removeDashEmail = (field: string): CleanOperation => ({
field
});

const removeMultipleAtEmail = (field: string): CleanOperation => ({
name: 'multiple at',
selector: /@.+@/u,
field
});

const cleanOperationIfAny = (
cleanOperator: (colonne: string, codePostal?: string) => CleanOperation,
colonne?: string,
Expand Down Expand Up @@ -365,5 +371,6 @@ export const cleanOperations = (
...cleanOperationIfAny(fixUnexpectedEmailList, matching.courriel?.colonne),
...cleanOperationIfAny(fixObfuscatedAtInEmail, matching.courriel?.colonne),
...cleanOperationIfAny(fixMissingEmailExtension, matching.courriel?.colonne),
...cleanOperationIfAny(removeMissingAtInEmail, matching.courriel?.colonne)
...cleanOperationIfAny(removeMissingAtInEmail, matching.courriel?.colonne),
...cleanOperationIfAny(removeMultipleAtEmail, matching.courriel?.colonne)
];
11 changes: 11 additions & 0 deletions src/transformer/fields/contact/contact.field.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1019,4 +1019,15 @@ describe('contact field', (): void => {
})
);
});

it('should remove email if multiple At', (): void => {
const contact: Contact = processContact(Report().entry(0))(
{
[EMAIL_FIELD]: 'msap@marchaux1@orange.fr'
} as DataSource,
matching
);

expect(contact).toStrictEqual<Contact>(Contact({}));
});
});

0 comments on commit 24ca20b

Please sign in to comment.