fix: replace certain characters with spaces

This commit is contained in:
Viren070
2025-10-23 14:41:56 +01:00
parent 98185137ba
commit 533e477da9
+10 -6
View File
@@ -83,13 +83,17 @@ export function normaliseTitle(title: string) {
}
export function cleanTitle(title: string) {
return title
.normalize('NFD')
.replace(/-/g, ' ')
let cleaned = title.normalize('NFD');
for (const char of ['♪', '♫', '★', '☆', '♡', '♥', '-']) {
cleaned = cleaned.replaceAll(char, ' ');
}
return cleaned
.replace(/&/g, 'and')
.replace(/[\u0300-\u036f]/g, '')
.replace(/[^\p{L}\p{N}\s]/gu, '')
.replace(/\s+/g, ' ')
.replace(/[\u0300-\u036f]/g, '') // Remove diacritics
.replace(/[^\p{L}\p{N}\s]/gu, '') // Remove remaining special chars
.replace(/\s+/g, ' ') // Normalise spaces
.toLowerCase()
.trim();
}