Convert back to server app from lambda function

This commit is contained in:
2024-01-17 19:56:31 +01:00
parent 023956514b
commit e53f948c20
8 changed files with 14 additions and 536 deletions

19
getPlaylistIdFromUrl.ts Normal file
View File

@@ -0,0 +1,19 @@
export const getPlaylistIdFromUrl = (url: string) => {
try {
const urlObject = new URL(url);
const [collectionName, playlistId] = urlObject.pathname
.split('/')
.filter(Boolean);
const isValidPlaylistUrl =
urlObject.hostname === 'open.spotify.com' &&
collectionName === 'playlist' &&
playlistId;
if (!isValidPlaylistUrl) return null;
return playlistId;
} catch {
return null;
}
};