Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to tolerate diacritics #39

Open
googol7 opened this issue Jun 30, 2017 · 1 comment
Open

Option to tolerate diacritics #39

googol7 opened this issue Jun 30, 2017 · 1 comment

Comments

@googol7
Copy link

googol7 commented Jun 30, 2017

It would be very helpful if an option could be set so that fuzzy would return strings with and without diacritics.

e.g.: The user searches for "Lumiere"

The result should also include "Lumière":

Lumière
Lümière
Lumiere
Lůmière
Lúmière

You won't find "Lumiere" in this official example:
http://htmlpreview.github.io/?https://github.com/mattyork/fuzzy/blob/master/examples/disney.html

@schindld
Copy link

schindld commented Mar 2, 2023

I got diacritics to be included in searches by changing 2 places in fuzzy.js where comparisons are done...

Line 50:

-    , compareString =  opts.caseSensitive && str || str.toLowerCase()
+    , compareString =  opts.caseSensitive && str || str.toLowerCase().normalize("NFKD").replace(/\p{Diacritic}/gu, "")
     , ch;
 
-  pattern = opts.caseSensitive && pattern || pattern.toLowerCase();
+  pattern = opts.caseSensitive && pattern || pattern.toLowerCase().normalize("NFKD").replace(/\p{Diacritic}/gu, "");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants