diff --git a/package.json b/package.json index e768d7c0..8f1565d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@editorjs/embed", - "version": "2.7.4", + "version": "2.7.5", "keywords": [ "codex editor", "embed", diff --git a/src/services.ts b/src/services.ts index e8188cd9..79115930 100644 --- a/src/services.ts +++ b/src/services.ts @@ -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: '', height: 505, width: 400, + id: (groups: string[]) => groups?.[0]?.split("/")[0], }, twitter: { regex: /^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)/, diff --git a/test/services.ts b/test/services.ts index b756d868..1685d840 100644 --- a/test/services.ts +++ b/test/services.ts @@ -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 => {