From e0851c9e4df695a19a5613ebc42f5ef32795ab4f Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Sat, 11 May 2024 11:09:36 -0700 Subject: [PATCH] chore: those names make more sense --- src/_data/albumReleases.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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 '' }