Skip to content

Commit

Permalink
Catch more types of search inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
silamon committed Jun 26, 2024
1 parent 4b7526c commit 679ad1e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/common/string/strip-diacritics.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
export const stripDiacritics = (str) =>
str.normalize("NFD").replace(/[\u0300-\u036F]/g, "");
export function stripDiacritics(
str: string | readonly string[] | undefined
): any {
if (str === undefined) {
return str;
}
if (typeof str === "string") {
return str.normalize("NFD").replace(/[\u0300-\u036F]/g, "");
}
return str.map((s) => s.normalize("NFD").replace(/[\u0300-\u036F]/g, ""));
}

0 comments on commit 679ad1e

Please sign in to comment.