mirror of
https://github.com/TheRealOwenRees/echecsfrance.git
synced 2026-07-23 04:26:57 +00:00
Improve search
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
export const removeDiacritics = (str: string) => {
|
||||
// We normalize to the composed Unicode form, then we can remove the accents
|
||||
return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
||||
};
|
||||
|
||||
export const normalizedContains = (haystack: string, needle: string) => {
|
||||
const regExp = new RegExp(removeDiacritics(needle), "gi");
|
||||
return regExp.test(removeDiacritics(haystack));
|
||||
};
|
||||
Reference in New Issue
Block a user