Skip to content

Commit

Permalink
Merge pull request #125 from Abhii5496/instagram-embed
Browse files Browse the repository at this point in the history
Instagram reels and post regex fixed
  • Loading branch information
neSpecc authored Oct 11, 2024
2 parents f2585ab + a64fec6 commit 747f9e7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 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.4",
"version": "2.7.5",
"keywords": [
"codex editor",
"embed",
Expand Down
4 changes: 3 additions & 1 deletion src/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,13 @@ const SERVICES: ServicesConfigType = {
id: (ids) => ids.join('/embed/'),
},
instagram: {
regex: /https?:\/\/www\.instagram\.com\/p\/([^\/\?\&]+)\/?.*/,
//it support both reel and post
regex: /^https:\/\/(?:www\.)?instagram\.com\/(?:reel|p)\/(.*)/,
embedUrl: 'https://www.instagram.com/p/<%= remote_id %>/embed',
html: '<iframe width="400" height="505" style="margin: 0 auto;" frameborder="0" scrolling="no" allowtransparency="true"></iframe>',
height: 505,
width: 400,
id: (groups: string[]) => groups?.[0]?.split("/")[0],
},
twitter: {
regex: /^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)/,
Expand Down
17 changes: 17 additions & 0 deletions test/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,23 @@ describe('Services Regexps', () => {
source: 'https://www.instagram.com/p/CfQzzGNphD8/?utm_source=ig_web_copy_link',
embed: 'https://www.instagram.com/p/CfQzzGNphD8/embed'
},
{
source: 'https://www.instagram.com/p/C4_Lsf1NBra/?img_index=1',
embed: 'https://www.instagram.com/p/C4_Lsf1NBra/embed'
},
{
source: 'https://www.instagram.com/p/C5ZZUWPydSY/?utm_source=ig_web_copy_link',
embed: 'https://www.instagram.com/p/C5ZZUWPydSY/embed'
},
{
source: 'https://www.instagram.com/reel/C19IuqJx6wm/',
embed: 'https://www.instagram.com/p/C19IuqJx6wm/embed'
},
{
source: 'https://www.instagram.com/reel/C19IuqJx6wm/?utm_source=ig_web_copy_link',
embed: 'https://www.instagram.com/p/C19IuqJx6wm/embed'
},

];

urls.forEach(url => {
Expand Down

0 comments on commit 747f9e7

Please sign in to comment.