From 720231c10886a7461eb6f5701cfbe1681db070dc Mon Sep 17 00:00:00 2001 From: Jannik Zinkl Date: Wed, 18 Oct 2023 15:50:15 +0200 Subject: [PATCH] fix: adding simple email check to prevent wrong email address sync --- pkg/integration-kencove-api/src/contacts.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/integration-kencove-api/src/contacts.ts b/pkg/integration-kencove-api/src/contacts.ts index 7b0240082..bb7ba119c 100644 --- a/pkg/integration-kencove-api/src/contacts.ts +++ b/pkg/integration-kencove-api/src/contacts.ts @@ -75,6 +75,14 @@ export class KencoveApiAppContactSyncService { } const email = contact.email.toLowerCase(); + // simple check if email is actually a valid email address, using regex + if (!email.match(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)) { + this.logger.warn( + `Skipping contact with invalid email address: ${email}`, + ); + continue; + } + const companyName = contact.companyname; const companyNameNormalized = normalizeStrings.companyNames( companyName || "",