/** * Case- and accent-insensitive substring match, the equivalent of ICU * "base" sensitivity for search: `Café` matches `cafe`, `STRASSE` matches * `strasse` after compatibility normalisation. */ const fold = (value: string) => value.normalize("NFKD").replace(/\p{Mn}/gu, ""); export function createBaseContains(locale?: string) { return (text: string, query: string) => { if (!query) return true; return fold(text) .toLocaleLowerCase(locale) .includes(fold(query).toLocaleLowerCase(locale)); }; }