diff --git a/src/_data/albumReleases.js b/src/_data/albumReleases.js index 0a5354da..b871f6b4 100644 --- a/src/_data/albumReleases.js +++ b/src/_data/albumReleases.js @@ -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 '' }