We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 4d3e452 + 3e7b342 commit af9679bCopy full SHA for af9679b
.changeset/clean-cups-sort.md
@@ -0,0 +1,5 @@
1
+---
2
+"@udecode/plate-media": patch
3
4
+
5
+fix: `parseTwitterUrl`
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+)/;
6
+const TWITTER_ID_INDEX = 3
7
8
export const parseTwitterUrl = (url: string): EmbedUrlData | undefined => {
- if (twitterRegex.exec(url)) {
9
+ const match = twitterRegex.exec(url);
10
+ if (match) {
11
return {
- id: twitterRegex.exec(url)?.groups?.id,
12
+ id: match[TWITTER_ID_INDEX],
13
provider: 'twitter',
14
url,
15
};
16
}
-};
17
+};
0 commit comments