From 4b634598863ae6b3f9039451c87e66d28e9047f2 Mon Sep 17 00:00:00 2001 From: Simon Nedjari Date: Sun, 17 Sep 2023 11:52:16 +0200 Subject: [PATCH] feature: add normalizeString func in isNormalizedStringEqual utils --- src/utils/isNormalizedStringEqual.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils/isNormalizedStringEqual.ts b/src/utils/isNormalizedStringEqual.ts index cd63e4b0f..10063aac9 100644 --- a/src/utils/isNormalizedStringEqual.ts +++ b/src/utils/isNormalizedStringEqual.ts @@ -1,8 +1,16 @@ // Normalise les chaînes de caractères et les compare pour retourner un boolean +export const normalizeString = (data: string): string => { + return data.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); +}; + export const isNormalizedStringEqual = (str1: string, str2: string): boolean => { const strNorm1 = str1.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); const strNorm2 = str2.normalize('NFD').replace(/[\u0300-\u036f]/g, ''); return strNorm1.toLocaleLowerCase() === strNorm2.toLocaleLowerCase(); }; + +// export const isNormalizedStringEqual = (str1: string, str2: string): boolean => { +// return normalizeString(str1).toLocaleLowerCase() === normalizeString(str2).toLocaleLowerCase(); +// };