diff --git a/functions/getProfileFlagsForIdentifier.protected.ts b/functions/getProfileFlagsForIdentifier.protected.ts index 1ba771e3..a3b82aec 100644 --- a/functions/getProfileFlagsForIdentifier.protected.ts +++ b/functions/getProfileFlagsForIdentifier.protected.ts @@ -71,14 +71,19 @@ const getContactValueFromWebchat = (trigger: ChatTrigger) => { return preEngagementData.contactIdentifier; }; -const trimSpaces = (s: string) => s.replace(' ', ''); - +/** + * IMPORTANT: keep up to date with flex-plugins/plugin-hrm-form/src/utils/task + */ +const trimSpaces = (s: string) => s.replaceAll(' ', ''); +const trimHyphens = (s: string) => s.replaceAll('-', ''); +const phoneNumberStandardization = (s: string) => + [trimSpaces, trimHyphens].reduce((accum, f) => f(accum), s); type TransformIdentifierFunction = (c: string) => string; const channelTransformations: { [k: string]: TransformIdentifierFunction[] } = { - voice: [trimSpaces], - sms: [trimSpaces], - whatsapp: [(s) => s.replace('whatsapp:', ''), trimSpaces], - modica: [(s) => s.replace('modica:', ''), trimSpaces], + voice: [phoneNumberStandardization], + sms: [phoneNumberStandardization], + whatsapp: [(s) => s.replace('whatsapp:', ''), phoneNumberStandardization], + modica: [(s) => s.replace('modica:', ''), phoneNumberStandardization], facebook: [(s) => s.replace('messenger:', '')], instagram: [], line: [], diff --git a/tsconfig.json b/tsconfig.json index 04c9b811..aedd9cd9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -8,7 +8,7 @@ // "incremental": true, /* Enable incremental compilation */ "target": "ES2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */ "module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */ - "lib": ["ES2020", "DOM"], /* Specify library files to be included in the compilation. */ + "lib": ["ES2021", "DOM"], /* Specify library files to be included in the compilation. */ // "allowJs": true, /* Allow javascript files to be compiled. */ // "checkJs": true, /* Report errors in .js files. */ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */