From 5530c453f9bac21c39d729c61ec352e5f45cf34e Mon Sep 17 00:00:00 2001 From: Sai Krishna Bendalam Date: Sat, 20 Apr 2024 04:41:51 +0530 Subject: [PATCH] fix: fixed regex pattern to work with all playlist links Subject: playlist controller regex pattern fix --- bun.lockb | Bin 313847 -> 313847 bytes package.json | 2 +- .../controllers/playlist.controller.ts | 8 +++++++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bun.lockb b/bun.lockb index 0c8e9d7451f57bda1b9fd109dba23fdb914bed52..bc5112b485937e43d24b1b35a73a61fdd51d6eec 100755 GIT binary patch delta 5524 zcmXBY`ycl79LI6@-EBE!Bu40xL+iY{(d0De-Ht<82ds!WPm~E+l9uC?+}E8j=Q(9^ zXgQ9;oQE*yIn|u!yc{oX@7E9C&-3wq{R!V|F4*Uq3-&qB*?-#igv;k^U9s2s`(3^F zDJPwJ;^`M1eexN{A9wL-&DrN%b02P($U zf_0E$0v)UlR!pG>`w+zp25=5l%wYugFvS8U@D5j8!wkNoSi%Cq5sDRTAUsmB24lNc z1Pz#XP>i7k>yC;Ebg;UUVhTOjM=547fa5CWFoJt$#R4Yqj#ga54E|jdOIRSdt6~Kk z2=As?gK>AQ2pTZ&p%_C8mZz9N2djH3rqF|ZFU1T7aPF;`!wBwu6bqQZyRYIJX7KN) zSi%Cq{S_L}paJs%iZQfcJy0=$4pt9ROrZz+!HO9S;5|QLJDC;bRqRFdnBBK?7!_7()xziHZqyusTUGg&yq3 zD`qf&^902lMsQD7EMNlfiHd8O!GDrs2@3?VVg(xrpR8De@f58H8Ze)#7()xz(-afv zVD)sx6ne0qp_st{&NCHr7{N^x3z)!rmf{*_@J~@JVS(V;iWO`ie2!ub#;IBnG+>^l z7()xza}^WlV3jJS(1ZOv#S8{;PFKuf1o!!h1x(<*KyeK-_%Bo}VS(Tb#R@hMzDThK zBh!kY0rO177+SDite8LttFshS=)r!8Vg>^^XDj9~g8Nd%0w(azQC!0eey&);0>Qb8 z6>K1UnPLsb%e5kCz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TgC3knF^2)%lN1XW z!F#x32^08_P+Y+b!6OwbSRj0q;uG+@Sx3AA86RxyPR?8hl)(1Y`M z#T*83PgX2o1n&uoB~0KyQE>$`1W!_|V1Y1ET*C&UCo9%qJVh&p2Fz0w6KKJDs$vQq z*iTc;pa*2F#Z$CeVWQ3dIyUuy-nE(1Y_z#T*83U!_>U2;QlRB~0MIT5$z41chP+3xuaB zu3-bwYZPlRUaJ*D1Lo@#6KKJDyBgCtr!|GuTV^&1?zi?DRf|eUonFooF6FWFo63*#R5j~exz8!1pbwZ zE0`e|6)RXE{ITL1HW2+pu?FL(S}`;7u?FL6tr!|G|E`!o3)VjrQ|Q3{ zr(y;@IR8@2VF35viUo||{YSBc3H*)X3T6oYt60Gz&JMTk`Dria8A69;8^n z2;L6G5+?8uR$Rdh!6AwjED#>5xP}cxhbh)zxLPqZU>>fRKnvCpiYat^*tPS7t*7rg Y;;5~ApSJtRt$W^H7w$fC?-S1XAAt4y>Hq)$ diff --git a/package.json b/package.json index ac233634..6f2832f2 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 45afbc95..f300524a 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',