From 9bb35be393373cd158cd29cdf9768f97000d364a Mon Sep 17 00:00:00 2001 From: Manas Paul Date: Tue, 29 Oct 2024 21:27:25 +0530 Subject: [PATCH] fix: Added support for youtube shorts --- package.json | 2 +- src/services.ts | 55 +++++---- test/services.ts | 294 +++++++++++++++++++++++++++++++++-------------- 3 files changed, 241 insertions(+), 110 deletions(-) diff --git a/package.json b/package.json index c1087c17..bb63bbc7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@editorjs/embed", - "version": "2.7.6", + "version": "2.7.7", "keywords": [ "codex editor", "embed", diff --git a/src/services.ts b/src/services.ts index 27e8e9c2..d5617fa1 100644 --- a/src/services.ts +++ b/src/services.ts @@ -3,14 +3,17 @@ import type { ServicesConfigType } from './serviceConfig'; const SERVICES: ServicesConfigType = { vimeo: { - regex: /(?:http[s]?:\/\/)?(?:www.)?(?:player.)?vimeo\.co(?:.+\/([^\/]\d+)(?:#t=[\d]+)?s?$)/, - embedUrl: 'https://player.vimeo.com/video/<%= remote_id %>?title=0&byline=0', + regex: + /(?:http[s]?:\/\/)?(?:www.)?(?:player.)?vimeo\.co(?:.+\/([^\/]\d+)(?:#t=[\d]+)?s?$)/, + embedUrl: + 'https://player.vimeo.com/video/<%= remote_id %>?title=0&byline=0', html: '', height: 320, width: 580, }, youtube: { - regex: /(?:https?:\/\/)?(?:www\.)?(?:(?:youtu\.be\/)|(?:youtube\.com)\/(?:v\/|u\/\w\/|embed\/|watch))(?:(?:\?v=)?([^#&?=]*))?((?:[?&]\w*=\w*)*)/, + regex: + /(?:https?:\/\/)?(?:www\.)?(?:(?:youtu\.be\/)|(?:youtube\.com)\/(?:v\/|u\/\w\/|embed\/|watch|shorts\/))(?:(?:\?v=)?([^#&?=]*))?((?:[?&]\w*=\w*)*)/, embedUrl: 'https://www.youtube.com/embed/<%= remote_id %>', html: '', height: 320, @@ -29,9 +32,10 @@ const SERVICES: ServicesConfigType = { list: 'list', }; - let newParams = params.slice(1) + let newParams = params + .slice(1) .split('&') - .map(param => { + .map((param) => { const [name, value] = param.split('='); if (!id && name === 'v') { @@ -40,19 +44,21 @@ const SERVICES: ServicesConfigType = { return null; } - if (!(paramsMap[name])) { + if (!paramsMap[name]) { return null; } - if (value === 'LL' || + if ( + value === 'LL' || value.startsWith('RDMM') || - value.startsWith('FL')) { + value.startsWith('FL') + ) { return null; } return `${paramsMap[name]}=${value}`; }) - .filter(param => !!param); + .filter((param) => !!param); return id + '?' + newParams.join('&'); }, @@ -101,22 +107,24 @@ const SERVICES: ServicesConfigType = { }, 'yandex-music-album': { regex: /https?:\/\/music\.yandex\.ru\/album\/([0-9]*)\/?$/, - embedUrl: 'https://music\.yandex\.ru/iframe/#album/<%= remote_id %>/', - html: '', + embedUrl: 'https://music.yandex.ru/iframe/#album/<%= remote_id %>/', + html: '', height: 400, width: 540, }, 'yandex-music-track': { regex: /https?:\/\/music\.yandex\.ru\/album\/([0-9]*)\/track\/([0-9]*)/, - embedUrl: 'https://music\.yandex\.ru/iframe/#track/<%= remote_id %>/', + embedUrl: 'https://music.yandex.ru/iframe/#track/<%= remote_id %>/', html: '', height: 100, width: 540, id: (ids) => ids.join('/'), }, 'yandex-music-playlist': { - regex: /https?:\/\/music\.yandex\.ru\/users\/([^\/\?\&]*)\/playlists\/([0-9]*)/, - embedUrl: 'https://music\.yandex\.ru/iframe/#playlist/<%= remote_id %>/show/cover/description/', + regex: + /https?:\/\/music\.yandex\.ru\/users\/([^\/\?\&]*)\/playlists\/([0-9]*)/, + embedUrl: + 'https://music.yandex.ru/iframe/#playlist/<%= remote_id %>/show/cover/description/', html: '', height: 400, width: 540, @@ -124,7 +132,8 @@ const SERVICES: ServicesConfigType = { }, codepen: { regex: /https?:\/\/codepen\.io\/([^\/\?\&]*)\/pen\/([^\/\?\&]*)/, - embedUrl: 'https://codepen.io/<%= remote_id %>?height=300&theme-id=0&default-tab=css,result&embed-version=2', + embedUrl: + 'https://codepen.io/<%= remote_id %>?height=300&theme-id=0&default-tab=css,result&embed-version=2', html: "", height: 300, width: 600, @@ -137,15 +146,16 @@ const SERVICES: ServicesConfigType = { html: '', height: 505, width: 400, - id: (groups: string[]) => groups?.[0]?.split("/")[0], + id: (groups: string[]) => groups?.[0]?.split('/')[0], }, twitter: { regex: /^https?:\/\/(www\.)?(?:twitter\.com|x\.com)\/.+\/status\/(\d+)/, - embedUrl: 'https://platform.twitter.com/embed/Tweet.html?id=<%= remote_id %>', + embedUrl: + 'https://platform.twitter.com/embed/Tweet.html?id=<%= remote_id %>', html: '', height: 300, width: 600, - id: ids => ids[1], + id: (ids) => ids[1], }, pinterest: { regex: /https?:\/\/([^\/\?\&]*).pinterest.com\/pin\/([^\/\?\&]*)\/?$/, @@ -157,7 +167,8 @@ const SERVICES: ServicesConfigType = { }, facebook: { regex: /https?:\/\/www.facebook.com\/([^\/\?\&]*)\/(.*)/, - embedUrl: 'https://www.facebook.com/plugins/post.php?href=https://www.facebook.com/<%= remote_id %>&width=500', + embedUrl: + 'https://www.facebook.com/plugins/post.php?href=https://www.facebook.com/<%= remote_id %>&width=500', html: "", id: (ids) => { return ids.join('/'); @@ -165,7 +176,8 @@ const SERVICES: ServicesConfigType = { }, aparat: { regex: /(?:http[s]?:\/\/)?(?:www.)?aparat\.com\/v\/([^\/\?\&]+)\/?/, - embedUrl: 'https://www.aparat.com/video/video/embed/videohash/<%= remote_id %>/vt/frame', + embedUrl: + 'https://www.aparat.com/video/video/embed/videohash/<%= remote_id %>/vt/frame', html: '', height: 300, width: 600, @@ -177,7 +189,8 @@ const SERVICES: ServicesConfigType = { }, github: { regex: /https?:\/\/gist.github.com\/([^\/\?\&]*)\/([^\/\?\&]*)/, - embedUrl: 'data:text/html;charset=utf-8,', + embedUrl: + 'data:text/html;charset=utf-8,', html: '', height: 300, width: 600, diff --git a/test/services.ts b/test/services.ts index 1685d840..9bdb84e5 100644 --- a/test/services.ts +++ b/test/services.ts @@ -3,16 +3,20 @@ import { expect } from 'chai'; import EmbedTool, { EmbedData } from '../src/index'; import { API } from '@editorjs/editorjs'; -EmbedTool.prepare({config: {}}); +EmbedTool.prepare({ config: {} }); const { patterns } = EmbedTool.pasteConfig; -const embed = new EmbedTool({data: {} as EmbedData, api: {} as API, readOnly: false}); +const embed = new EmbedTool({ + data: {} as EmbedData, + api: {} as API, + readOnly: false, +}); const composePasteEventMock = (type: string, service: string, url: string) => ({ type, detail: { key: service, - data: url - } + data: url, + }, }); describe('Services Regexps', () => { @@ -20,15 +24,45 @@ describe('Services Regexps', () => { const service = 'youtube'; const urls = [ - { source: 'https://www.youtube.com/watch?v=wZZ7oFKsKzY&t=120', embed: 'https://www.youtube.com/embed/wZZ7oFKsKzY?start=120' }, - { source: 'https://www.youtube.com/embed/_q51LZ2HpbE?list=PLLy6qvPKpdlV3OAw00EuZMoYPz4pYuwuN', embed: 'https://www.youtube.com/embed/_q51LZ2HpbE?list=PLLy6qvPKpdlV3OAw00EuZMoYPz4pYuwuN' }, - { source: 'https://www.youtube.com/watch?time_continue=173&v=Nd9LbCWpHp8', embed: 'https://www.youtube.com/embed/Nd9LbCWpHp8?start=173' }, - { source: 'https://www.youtube.com/watch?v=efBBjIK3b8I&list=LL&t=1337', embed: 'https://www.youtube.com/embed/efBBjIK3b8I?start=1337' }, - { source: 'https://www.youtube.com/watch?v=yQUeAin7fII&list=RDMMnMXCzscqi_M', embed: 'https://www.youtube.com/embed/yQUeAin7fII?' }, - { source: 'https://www.youtube.com/watch?v=3kw2sttGXMI&list=FLgc4xqIMDoiP4KOTFS21TJA', embed: 'https://www.youtube.com/embed/3kw2sttGXMI?' }, + { + source: 'https://www.youtube.com/watch?v=wZZ7oFKsKzY&t=120', + embed: 'https://www.youtube.com/embed/wZZ7oFKsKzY?start=120', + }, + { + source: + 'https://www.youtube.com/embed/_q51LZ2HpbE?list=PLLy6qvPKpdlV3OAw00EuZMoYPz4pYuwuN', + embed: + 'https://www.youtube.com/embed/_q51LZ2HpbE?list=PLLy6qvPKpdlV3OAw00EuZMoYPz4pYuwuN', + }, + { + source: 'https://www.youtube.com/watch?time_continue=173&v=Nd9LbCWpHp8', + embed: 'https://www.youtube.com/embed/Nd9LbCWpHp8?start=173', + }, + { + source: 'https://www.youtube.com/watch?v=efBBjIK3b8I&list=LL&t=1337', + embed: 'https://www.youtube.com/embed/efBBjIK3b8I?start=1337', + }, + { + source: + 'https://www.youtube.com/watch?v=yQUeAin7fII&list=RDMMnMXCzscqi_M', + embed: 'https://www.youtube.com/embed/yQUeAin7fII?', + }, + { + source: + 'https://www.youtube.com/watch?v=3kw2sttGXMI&list=FLgc4xqIMDoiP4KOTFS21TJA', + embed: 'https://www.youtube.com/embed/3kw2sttGXMI?', + }, + { + source: 'https://www.youtube.com/shorts/AAcP_D8fz5c', + embed: 'https://www.youtube.com/embed/AAcP_D8fz5c', + }, + { + source: 'https://youtube.com/shorts/AAcP_D8fz5c?si=79yc6fwUcvsL-FY_', + embed: 'https://www.youtube.com/embed/AAcP_D8fz5c?', + }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -45,12 +79,21 @@ describe('Services Regexps', () => { const service = 'vimeo'; const urls = [ - { source: 'https://vimeo.com/289836809', embed: 'https://player.vimeo.com/video/289836809?title=0&byline=0' }, - { source: 'https://www.vimeo.com/280712228', embed: 'https://player.vimeo.com/video/280712228?title=0&byline=0' }, - { source: 'https://player.vimeo.com/video/504749530', embed: 'https://player.vimeo.com/video/504749530?title=0&byline=0' } + { + source: 'https://vimeo.com/289836809', + embed: 'https://player.vimeo.com/video/289836809?title=0&byline=0', + }, + { + source: 'https://www.vimeo.com/280712228', + embed: 'https://player.vimeo.com/video/280712228?title=0&byline=0', + }, + { + source: 'https://player.vimeo.com/video/504749530', + embed: 'https://player.vimeo.com/video/504749530?title=0&byline=0', + }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -67,11 +110,17 @@ describe('Services Regexps', () => { const service = 'coub'; const urls = [ - { source: 'https://coub.com/view/1efrxs', embed: 'https://coub.com/embed/1efrxs' }, - { source: 'https://coub.com/view/1c6nrr', embed: 'https://coub.com/embed/1c6nrr' } + { + source: 'https://coub.com/view/1efrxs', + embed: 'https://coub.com/embed/1efrxs', + }, + { + source: 'https://coub.com/view/1c6nrr', + embed: 'https://coub.com/embed/1c6nrr', + }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -87,11 +136,17 @@ describe('Services Regexps', () => { const service = 'imgur'; const urls = [ - { source: 'https://imgur.com/gallery/OHbkxgr', embed: 'http://imgur.com/OHbkxgr/embed' }, - { source: 'https://imgur.com/gallery/TqIWG12', embed: 'http://imgur.com/TqIWG12/embed' } + { + source: 'https://imgur.com/gallery/OHbkxgr', + embed: 'http://imgur.com/OHbkxgr/embed', + }, + { + source: 'https://imgur.com/gallery/TqIWG12', + embed: 'http://imgur.com/TqIWG12/embed', + }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -108,11 +163,17 @@ describe('Services Regexps', () => { const service = 'gfycat'; const urls = [ - { source: 'https://gfycat.com/EsteemedMarvelousHagfish', embed: 'https://gfycat.com/ifr/EsteemedMarvelousHagfish' }, - { source: 'https://gfycat.com/OddCornyLeech', embed: 'https://gfycat.com/ifr/OddCornyLeech' } + { + source: 'https://gfycat.com/EsteemedMarvelousHagfish', + embed: 'https://gfycat.com/ifr/EsteemedMarvelousHagfish', + }, + { + source: 'https://gfycat.com/OddCornyLeech', + embed: 'https://gfycat.com/ifr/OddCornyLeech', + }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -128,11 +189,17 @@ describe('Services Regexps', () => { const service = 'twitch-channel'; const urls = [ - { source: 'https://www.twitch.tv/ninja', embed: 'https://player.twitch.tv/?channel=ninja' }, - { source: 'https://www.twitch.tv/gohamedia', embed: 'https://player.twitch.tv/?channel=gohamedia' } + { + source: 'https://www.twitch.tv/ninja', + embed: 'https://player.twitch.tv/?channel=ninja', + }, + { + source: 'https://www.twitch.tv/gohamedia', + embed: 'https://player.twitch.tv/?channel=gohamedia', + }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -148,11 +215,17 @@ describe('Services Regexps', () => { const service = 'twitch-video'; const urls = [ - { source: 'https://www.twitch.tv/videos/315468440', embed: 'https://player.twitch.tv/?video=v315468440' }, - { source: 'https://www.twitch.tv/videos/314691366', embed: 'https://player.twitch.tv/?video=v314691366' } + { + source: 'https://www.twitch.tv/videos/315468440', + embed: 'https://player.twitch.tv/?video=v315468440', + }, + { + source: 'https://www.twitch.tv/videos/314691366', + embed: 'https://player.twitch.tv/?video=v314691366', + }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -169,11 +242,17 @@ describe('Services Regexps', () => { const service = 'yandex-music-album'; const urls = [ - { source: 'https://music.yandex.ru/album/5643859', embed: 'https://music.yandex.ru/iframe/#album/5643859/' }, - { source: 'https://music.yandex.ru/album/5393158', embed: 'https://music.yandex.ru/iframe/#album/5393158/' } + { + source: 'https://music.yandex.ru/album/5643859', + embed: 'https://music.yandex.ru/iframe/#album/5643859/', + }, + { + source: 'https://music.yandex.ru/album/5393158', + embed: 'https://music.yandex.ru/iframe/#album/5393158/', + }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -190,11 +269,17 @@ describe('Services Regexps', () => { const service = 'yandex-music-track'; const urls = [ - { source: 'https://music.yandex.ru/album/5643859/track/42662275', embed: 'https://music.yandex.ru/iframe/#track/5643859/42662275/' }, - { source: 'https://music.yandex.ru/album/5393158/track/41249158', embed: 'https://music.yandex.ru/iframe/#track/5393158/41249158/' } + { + source: 'https://music.yandex.ru/album/5643859/track/42662275', + embed: 'https://music.yandex.ru/iframe/#track/5643859/42662275/', + }, + { + source: 'https://music.yandex.ru/album/5393158/track/41249158', + embed: 'https://music.yandex.ru/iframe/#track/5393158/41249158/', + }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -211,11 +296,21 @@ describe('Services Regexps', () => { const service = 'yandex-music-playlist'; const urls = [ - { source: 'https://music.yandex.ru/users/yamusic-personal/playlists/25098905', embed: 'https://music.yandex.ru/iframe/#playlist/yamusic-personal/25098905/show/cover/description/' }, - { source: 'https://music.yandex.ru/users/yamusic-personal/playlists/27924603', embed: 'https://music.yandex.ru/iframe/#playlist/yamusic-personal/27924603/show/cover/description/' } + { + source: + 'https://music.yandex.ru/users/yamusic-personal/playlists/25098905', + embed: + 'https://music.yandex.ru/iframe/#playlist/yamusic-personal/25098905/show/cover/description/', + }, + { + source: + 'https://music.yandex.ru/users/yamusic-personal/playlists/27924603', + embed: + 'https://music.yandex.ru/iframe/#playlist/yamusic-personal/27924603/show/cover/description/', + }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -231,11 +326,19 @@ describe('Services Regexps', () => { const service = 'codepen'; const urls = [ - { source: 'https://codepen.io/Rikkokiri/pen/RYBrwG', embed: 'https://codepen.io/Rikkokiri/embed/RYBrwG?height=300&theme-id=0&default-tab=css,result&embed-version=2' }, - { source: 'https://codepen.io/geoffgraham/pen/bxEVEN', embed: 'https://codepen.io/geoffgraham/embed/bxEVEN?height=300&theme-id=0&default-tab=css,result&embed-version=2' } + { + source: 'https://codepen.io/Rikkokiri/pen/RYBrwG', + embed: + 'https://codepen.io/Rikkokiri/embed/RYBrwG?height=300&theme-id=0&default-tab=css,result&embed-version=2', + }, + { + source: 'https://codepen.io/geoffgraham/pen/bxEVEN', + embed: + 'https://codepen.io/geoffgraham/embed/bxEVEN?height=300&theme-id=0&default-tab=css,result&embed-version=2', + }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -254,19 +357,23 @@ describe('Services Regexps', () => { const urls = [ { source: 'https://twitter.com/codex_team/status/1202295536826630145', - embed: 'https://platform.twitter.com/embed/Tweet.html?id=1202295536826630145' + embed: + 'https://platform.twitter.com/embed/Tweet.html?id=1202295536826630145', }, { - source: 'https://twitter.com/codex_team/status/1202295536826630145?s=20&t=wrY8ei5GBjbbmNonrEm2kQ', - embed: 'https://platform.twitter.com/embed/Tweet.html?id=1202295536826630145' + 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' + embed: + 'https://platform.twitter.com/embed/Tweet.html?id=1202295536826630145', }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -285,32 +392,34 @@ describe('Services Regexps', () => { const urls = [ { source: 'https://www.instagram.com/p/B--iRCFHVxI/', - embed: 'https://www.instagram.com/p/B--iRCFHVxI/embed' + embed: 'https://www.instagram.com/p/B--iRCFHVxI/embed', }, { - 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/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' + 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/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' + 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' + source: + 'https://www.instagram.com/reel/C19IuqJx6wm/?utm_source=ig_web_copy_link', + embed: 'https://www.instagram.com/p/C19IuqJx6wm/embed', }, - ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -327,11 +436,12 @@ describe('Services Regexps', () => { const urls = [ { source: 'https://www.aparat.com/v/tDZe5', - embed: 'https://www.aparat.com/video/video/embed/videohash/tDZe5/vt/frame' + embed: + 'https://www.aparat.com/video/video/embed/videohash/tDZe5/vt/frame', }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -354,22 +464,21 @@ describe('Services Regexps', () => { 'twitch-channel': 'https://www.twitch.tv/ninja', 'twitch-video': 'https://www.twitch.tv/videos/315468440', 'yandex-music-album': 'https://music.yandex.ru/album/5643859', - 'yandex-music-track': 'https://music.yandex.ru/album/5643859/track/42662275', - 'yandex-music-playlist': 'https://music.yandex.ru/users/yamusic-personal/playlists/25098905', - 'codepen': 'https://codepen.io/Rikkokiri/pen/RYBrwG' + 'yandex-music-track': + 'https://music.yandex.ru/album/5643859/track/42662275', + 'yandex-music-playlist': + 'https://music.yandex.ru/users/yamusic-personal/playlists/25098905', + codepen: 'https://codepen.io/Rikkokiri/pen/RYBrwG', }; - Object - .entries(services) - .forEach(([name, url]) => { - const foundService = Object.entries(patterns).find(([key, pattern]) => { - return pattern.test(url); - }); - - expect(foundService![0]).to.be.equal(name); + Object.entries(services).forEach(([name, url]) => { + const foundService = Object.entries(patterns).find(([key, pattern]) => { + return pattern.test(url); }); - }); + expect(foundService![0]).to.be.equal(name); + }); + }); it('Pinterest', async () => { const service = 'pinterest'; @@ -377,11 +486,12 @@ describe('Services Regexps', () => { const urls = [ { source: 'https://tr.pinterest.com/pin/409757266103637553/', - embed: 'https://assets.pinterest.com/ext/embed.html?id=409757266103637553' + embed: + 'https://assets.pinterest.com/ext/embed.html?id=409757266103637553', }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -399,16 +509,19 @@ describe('Services Regexps', () => { const urls = [ { - source: 'https://www.facebook.com/genclikforeverresmi/videos/944647522284479', - embed: 'https://www.facebook.com/plugins/post.php?href=https://www.facebook.com/genclikforeverresmi/videos/944647522284479&width=500' + source: + 'https://www.facebook.com/genclikforeverresmi/videos/944647522284479', + embed: + 'https://www.facebook.com/plugins/post.php?href=https://www.facebook.com/genclikforeverresmi/videos/944647522284479&width=500', }, { - source:'https://www.facebook.com/0devco/posts/497515624410920', - embed: 'https://www.facebook.com/plugins/post.php?href=https://www.facebook.com/0devco/posts/497515624410920&width=500' - } + source: 'https://www.facebook.com/0devco/posts/497515624410920', + embed: + 'https://www.facebook.com/plugins/post.php?href=https://www.facebook.com/0devco/posts/497515624410920&width=500', + }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -426,16 +539,20 @@ describe('Services Regexps', () => { const urls = [ { - source: 'https://gist.github.com/userharis/091b56505c804276e1f91925976f11db', - embed: 'data:text/html;charset=utf-8,', + source: + 'https://gist.github.com/userharis/091b56505c804276e1f91925976f11db', + embed: + 'data:text/html;charset=utf-8,', }, { - source: 'https://gist.github.com/userharis/a8c2977094d4716c43e35e6c20b7d306', - embed: 'data:text/html;charset=utf-8,', + source: + 'https://gist.github.com/userharis/a8c2977094d4716c43e35e6c20b7d306', + embed: + 'data:text/html;charset=utf-8,', }, ]; - urls.forEach(url => { + urls.forEach((url) => { expect(patterns[service].test(url.source)).to.be.true; const event = composePasteEventMock('pattern', service, url.source); @@ -458,8 +575,9 @@ describe('Miro service', () => { expect(patterns.miro.test(regularBoardUrl)).to.be.true; expect(embed.data.service).to.be.equal('miro'); - expect(embed.data.embed).to.be.equal('https://miro.com/app/live-embed/10J_kw57KxQ='); + expect(embed.data.embed).to.be.equal( + 'https://miro.com/app/live-embed/10J_kw57KxQ=' + ); expect(embed.data.source).to.be.equal(regularBoardUrl); - }) + }); }); -