diff --git a/bun.lockb b/bun.lockb index 0c8e9d7..bc5112b 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index ac23363..6f2832f 100644 --- a/package.json +++ b/package.json @@ -70,4 +70,4 @@ "typescript": "^5.4.3", "vitest": "^1.4.0" } -} \ No newline at end of file +} diff --git a/src/modules/playlists/controllers/playlist.controller.ts b/src/modules/playlists/controllers/playlist.controller.ts index 45afbc9..f300524 100644 --- a/src/modules/playlists/controllers/playlist.controller.ts +++ b/src/modules/playlists/controllers/playlist.controller.ts @@ -34,7 +34,13 @@ export class PlaylistController implements Routes { .string() .url() .optional() - .transform((value) => value?.match(/jiosaavn\.com\/featured\/[^/]+\/([^/]+)$/)?.[1]) + .transform((value) => { + const matches = value?.match( + /(?:jiosaavn\.com|saavn\.com)\/(?:featured|s\/playlist)\/[^/]+\/([^/]+)$|(?:\/([^/]+)$)/ + ) + const filteredMatches = matches?.filter((each) => each !== undefined) + return (filteredMatches && filteredMatches[filteredMatches?.length - 1 || 0]) || undefined + }) .openapi({ title: 'Playlist Link', description: 'A direct link to the playlist on JioSaavn',