Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: twitter (support both x.com and twitter.com) urls #127

Merged
merged 4 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading