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 bbf14cd2a8
commit 4216c86748

View File

@@ -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<TmdbSearchPersonResponse>(
'/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;
});