fix: no more repeated character ''' in the same character class
This commit is contained in:
@@ -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;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user