Skip to content

Commit

Permalink
fix: fixed regex pattern to work with all playlist links
Browse files Browse the repository at this point in the history
Subject: playlist controller regex pattern fix
  • Loading branch information
Sai Krishna Bendalam committed Apr 19, 2024
1 parent d231de2 commit 5530c45
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@
"typescript": "^5.4.3",
"vitest": "^1.4.0"
}
}
}
8 changes: 7 additions & 1 deletion src/modules/playlists/controllers/playlist.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 5530c45

Please sign in to comment.