Skip to content

Commit af9679b

Browse files
authored
Merge pull request #3796 from siosio34/main
fix: parseTwitterUrl logic
2 parents 4d3e452 + 3e7b342 commit af9679b

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.changeset/clean-cups-sort.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@udecode/plate-media": patch
3+
---
4+
5+
fix: `parseTwitterUrl`

packages/media/src/lib/media-embed/parseTwitterUrl.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@ import type { EmbedUrlData } from '../media/parseMediaUrl';
33
const twitterRegex =
44
/^https?:\/\/(?:twitter|x)\.com\/(?:#!\/)?(\w+)\/status(es)?\/(\d+)/;
55

6+
const TWITTER_ID_INDEX = 3
7+
68
export const parseTwitterUrl = (url: string): EmbedUrlData | undefined => {
7-
if (twitterRegex.exec(url)) {
9+
const match = twitterRegex.exec(url);
10+
if (match) {
811
return {
9-
id: twitterRegex.exec(url)?.groups?.id,
12+
id: match[TWITTER_ID_INDEX],
1013
provider: 'twitter',
1114
url,
1215
};
1316
}
14-
};
17+
};

0 commit comments

Comments
 (0)