chore: those names make more sense

This commit is contained in:
Cory Dransfeldt 2024-05-11 11:09:36 -07:00
parent 8310892e6c
commit e0851c9e4d
No known key found for this signature in database

View file

@ -6,14 +6,14 @@ const SUPABASE_KEY = process.env.SUPABASE_KEY
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY)
const deriveArtistName = (albumName, key) => {
const normalizedInput = albumName.toLowerCase().replace(/[\s.]+/g, '-').replace(/[^a-z0-9-]/g, '')
if (key.endsWith(normalizedInput)) {
const nonMatchingPart = key.slice(0, key.length - normalizedInput.length).replace(/-$/, '')
const capitalized = nonMatchingPart
const normalizedAlbumName = albumName.toLowerCase().replace(/[\s.]+/g, '-').replace(/[^a-z0-9-]/g, '')
if (key.endsWith(normalizedAlbumName)) {
const artistName = key.slice(0, key.length - normalizedAlbumName.length).replace(/-$/, '')
const formattedArtistName = artistName
.split('-')
.map(part => part.charAt(0).toUpperCase() + part.slice(1))
.join(' ')
return capitalized
return formattedArtistName
} else {
return ''
}