Skip to content

Commit

Permalink
Merge pull request #3796 from siosio34/main
Browse files Browse the repository at this point in the history
fix: parseTwitterUrl logic
  • Loading branch information
zbeyens authored Nov 21, 2024
2 parents 4d3e452 + 3e7b342 commit af9679b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/clean-cups-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@udecode/plate-media": patch
---

fix: `parseTwitterUrl`
9 changes: 6 additions & 3 deletions packages/media/src/lib/media-embed/parseTwitterUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
}
};
};

0 comments on commit af9679b

Please sign in to comment.