Skip to content

Commit

Permalink
feature: add normalizeString func in isNormalizedStringEqual utils
Browse files Browse the repository at this point in the history
  • Loading branch information
SimNed committed Sep 17, 2023
1 parent d2218c3 commit 4b63459
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/utils/isNormalizedStringEqual.ts
Original file line number Diff line number Diff line change
@@ -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();
// };

0 comments on commit 4b63459

Please sign in to comment.