From 0da8f17ee1c2760ea99c68d01a95dfb7ee6ab7b3 Mon Sep 17 00:00:00 2001 From: heka Date: Thu, 21 Nov 2024 17:10:58 +0900 Subject: [PATCH 1/2] fix: parseTwitterUrl logic --- packages/media/src/lib/media-embed/parseTwitterUrl.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/media/src/lib/media-embed/parseTwitterUrl.ts b/packages/media/src/lib/media-embed/parseTwitterUrl.ts index 1c9e5961da..acec9dd685 100644 --- a/packages/media/src/lib/media-embed/parseTwitterUrl.ts +++ b/packages/media/src/lib/media-embed/parseTwitterUrl.ts @@ -3,12 +3,15 @@ import type { EmbedUrlData } from '../media/parseMediaUrl'; const twitterRegex = /^https?:\/\/(?:twitter|x)\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)/; +const TWITTER_ID_INDEX = 3 + export const parseTwitterUrl = (url: string): EmbedUrlData | undefined => { - if (twitterRegex.exec(url)) { + const match = twitterRegex.exec(url); + if (match) { return { - id: twitterRegex.exec(url)?.groups?.id, + id: match[TWITTER_ID_INDEX], provider: 'twitter', url, }; } -}; +}; \ No newline at end of file From 3e7b342aec98f5f86f0127aaf34867268a66e274 Mon Sep 17 00:00:00 2001 From: Ziad Beyens Date: Thu, 21 Nov 2024 12:38:33 +0100 Subject: [PATCH 2/2] Create clean-cups-sort.md --- .changeset/clean-cups-sort.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/clean-cups-sort.md diff --git a/.changeset/clean-cups-sort.md b/.changeset/clean-cups-sort.md new file mode 100644 index 0000000000..6acf7b8ccd --- /dev/null +++ b/.changeset/clean-cups-sort.md @@ -0,0 +1,5 @@ +--- +"@udecode/plate-media": patch +--- + +fix: `parseTwitterUrl`