diff --git a/web/src/components/Suggestion.tsx b/web/src/components/Suggestion.tsx index da51b70..b016792 100644 --- a/web/src/components/Suggestion.tsx +++ b/web/src/components/Suggestion.tsx @@ -7,6 +7,7 @@ import {TiArrowSync} from 'react-icons/ti'; import {capitalize, stem, germanify, njoin, lower, upper} from '../util/text'; import {sampleFromArray, fillArray} from '../util/array'; import {mobile} from '../util/css'; +import {sanitize} from '../util/text'; type Modifier = (word: string) => string; @@ -141,7 +142,9 @@ async function findSynonyms(word: string): Promise { [] as string[], ), ), - ).filter((word) => !/[\s-]/.exec(word)); + ) + .filter((word) => !/[\s-]/.exec(word)) + .map((word) => sanitize(word)); return synonyms; } catch (err) { return []; diff --git a/web/src/util/text.ts b/web/src/util/text.ts index ce11c85..b965e50 100644 --- a/web/src/util/text.ts +++ b/web/src/util/text.ts @@ -4,7 +4,10 @@ export function capitalize(text: string): string { } export function sanitize(text: string): string { - return text.replace(/[\s@+!#$%^&*()[\]./<>{}]/g, ''); + return text + .replace(/[\s@+!#$%^&*()[\]./<>{}]/g, '') + .normalize('NFD') + .replace(/[\u0300-\u036f]/g, ''); } export function upper(word: string): string {