mirror of
https://github.com/uetchy/namae.git
synced 2025-08-20 09:58:13 +09:00
fix: normalize diacritics
This commit is contained in:
@@ -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<string[]> {
|
||||
[] as string[],
|
||||
),
|
||||
),
|
||||
).filter((word) => !/[\s-]/.exec(word));
|
||||
)
|
||||
.filter((word) => !/[\s-]/.exec(word))
|
||||
.map((word) => sanitize(word));
|
||||
return synonyms;
|
||||
} catch (err) {
|
||||
return [];
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user