Enhance search #215

Merged
enes merged 4 commits from issues/212-improved-search into staging 2025-02-04 09:27:09 +00:00
2 changed files with 4 additions and 2 deletions
Showing only changes of commit 688e9fcf6d - Show all commits

View File

@ -37,6 +37,7 @@ import {
extractModData, extractModData,
isModDataComplete, isModDataComplete,
memoizedNormalizeSearchString, memoizedNormalizeSearchString,
normalizeSearchString,
scrollIntoView scrollIntoView
} from 'utils' } from 'utils'
import { useCuratedSet } from 'hooks/useCuratedSet' import { useCuratedSet } from 'hooks/useCuratedSet'
@ -503,7 +504,7 @@ const GamesResult = ({ searchTerm }: GamesResultProps) => {
const filteredGames = useMemo(() => { const filteredGames = useMemo(() => {
if (searchTerm === '') return [] if (searchTerm === '') return []
const normalizedSearchTerm = memoizedNormalizeSearchString(searchTerm) const normalizedSearchTerm = normalizeSearchString(searchTerm)
return games.filter((game) => return games.filter((game) =>
memoizedNormalizeSearchString(game['Game Name']).includes( memoizedNormalizeSearchString(game['Game Name']).includes(

View File

@ -239,9 +239,10 @@ const romanRegex = new RegExp(
export const normalizeSearchString = (str: string): string => { export const normalizeSearchString = (str: string): string => {
str = str.toLowerCase() str = str.toLowerCase()
str = str.replace(romanRegex, (match) => ROMAN_TO_ARABIC_MAP[match])
str = removeAccents(str) str = removeAccents(str)
str = removeSpecialCharacters(str) str = removeSpecialCharacters(str)
return str.replace(romanRegex, (match) => ROMAN_TO_ARABIC_MAP[match]) return str
} }
// Memoization function to cache normalized results // Memoization function to cache normalized results