fix: no more repeated character ''' in the same character class

This commit is contained in:
Pierre
2025-03-10 18:58:14 +01:00
committed by HiItsStolas
parent be3aa05bc9
commit 3b4529f3b1

View File

@@ -138,7 +138,7 @@ class TmdbPersonMapper extends ExternalAPI {
const cleanArtistName = artistName const cleanArtistName = artistName
.split(/(?:(?:feat|ft)\.?\s+|&\s*|,\s+)/i)[0] .split(/(?:(?:feat|ft)\.?\s+|&\s*|,\s+)/i)[0]
.trim() .trim()
.replace(/['']/g, "'"); .replace(/['']/g, "'");
const searchResults = await this.get<TmdbSearchPersonResponse>( const searchResults = await this.get<TmdbSearchPersonResponse>(
'/search/person', '/search/person',
@@ -151,22 +151,19 @@ class TmdbPersonMapper extends ExternalAPI {
this.CACHE_TTL this.CACHE_TTL
); );
const exactMatches = searchResults.results.filter((person) => { const normalizeName = (name: string): string => {
const normalizedPersonName = person.name return name
.toLowerCase() .toLowerCase()
.normalize('NFKD') .normalize('NFKD')
.replace(/[\u0300-\u036f]/g, '') .replace(/[\u0300-\u036f]/g, '')
.replace(/['']/g, "'") .replace(/['']/g, "'")
.replace(/[^a-z0-9\s]/g, '') .replace(/[^a-z0-9\s]/g, '')
.trim(); .trim();
};
const normalizedArtistName = cleanArtistName const exactMatches = searchResults.results.filter((person) => {
.toLowerCase() const normalizedPersonName = normalizeName(person.name);
.normalize('NFKD') const normalizedArtistName = normalizeName(cleanArtistName);
.replace(/[\u0300-\u036f]/g, '')
.replace(/['']/g, "'")
.replace(/[^a-z0-9\s]/g, '')
.trim();
return normalizedPersonName === normalizedArtistName; return normalizedPersonName === normalizedArtistName;
}); });