From 3b4529f3b1bdb56dafe595e92c0c0a280e2cf979 Mon Sep 17 00:00:00 2001 From: Pierre <63404022+0-Pierre@users.noreply.github.com> Date: Mon, 10 Mar 2025 18:58:14 +0100 Subject: [PATCH] fix: no more repeated character ''' in the same character class --- server/api/themoviedb/personMapper.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/server/api/themoviedb/personMapper.ts b/server/api/themoviedb/personMapper.ts index d0438e6c..9ee5f930 100644 --- a/server/api/themoviedb/personMapper.ts +++ b/server/api/themoviedb/personMapper.ts @@ -138,7 +138,7 @@ class TmdbPersonMapper extends ExternalAPI { const cleanArtistName = artistName .split(/(?:(?:feat|ft)\.?\s+|&\s*|,\s+)/i)[0] .trim() - .replace(/['']/g, "'"); + .replace(/['′']/g, "'"); const searchResults = await this.get( '/search/person', @@ -151,22 +151,19 @@ class TmdbPersonMapper extends ExternalAPI { this.CACHE_TTL ); - const exactMatches = searchResults.results.filter((person) => { - const normalizedPersonName = person.name + const normalizeName = (name: string): string => { + return name .toLowerCase() .normalize('NFKD') .replace(/[\u0300-\u036f]/g, '') - .replace(/['']/g, "'") + .replace(/['′']/g, "'") .replace(/[^a-z0-9\s]/g, '') .trim(); + }; - const normalizedArtistName = cleanArtistName - .toLowerCase() - .normalize('NFKD') - .replace(/[\u0300-\u036f]/g, '') - .replace(/['']/g, "'") - .replace(/[^a-z0-9\s]/g, '') - .trim(); + const exactMatches = searchResults.results.filter((person) => { + const normalizedPersonName = normalizeName(person.name); + const normalizedArtistName = normalizeName(cleanArtistName); return normalizedPersonName === normalizedArtistName; });