Skip to content

Commit

Permalink
Merge pull request #127 from hortopan/master
Browse files Browse the repository at this point in the history
fix: twitter (support both x.com and twitter.com) urls
  • Loading branch information
neSpecc committed May 17, 2024
2 parents dfdbf24 + 4b86aaf commit e3922a4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@editorjs/embed",
"version": "2.7.1",
"version": "2.7.2",
"keywords": [
"codex editor",
"embed",
Expand Down
8 changes: 4 additions & 4 deletions src/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export default {
return null;
}

if (value === 'LL'
|| value.startsWith('RDMM')
|| value.startsWith('FL')) {
if (value === 'LL' ||
value.startsWith('RDMM') ||
value.startsWith('FL')) {
return null;
}

Expand Down Expand Up @@ -136,7 +136,7 @@ export default {
width: 400,
},
twitter: {
regex: /^https?:\/\/(www\.)?twitter\.com\/.+\/status\/(\d+)/,
regex: /^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)/,
embedUrl: 'https://platform.twitter.com/embed/Tweet.html?id=<%= remote_id %>',
html: '<iframe width="600" height="600" style="margin: 0 auto;" frameborder="0" scrolling="no" allowtransparency="true"></iframe>',
height: 300,
Expand Down
4 changes: 4 additions & 0 deletions test/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ describe('Services Regexps', () => {
source: 'https://twitter.com/codex_team/status/1202295536826630145?s=20&t=wrY8ei5GBjbbmNonrEm2kQ',
embed: 'https://platform.twitter.com/embed/Tweet.html?id=1202295536826630145'
},
{
source: 'https://x.com/codex_team/status/1202295536826630145',
embed: 'https://platform.twitter.com/embed/Tweet.html?id=1202295536826630145'
},
];

urls.forEach(url => {
Expand Down

0 comments on commit e3922a4

Please sign in to comment.