Skip to content

Commit aebea4a

Browse files
authored
Merge pull request #149 from editor-js/yandex-music-track
fix(yandex-music): improve track pattern
2 parents 6fb87aa + ae2da5c commit aebea4a

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/services.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ const SERVICES: ServicesConfigType = {
113113
width: 540,
114114
},
115115
'yandex-music-track': {
116-
regex: /https?:\/\/music\.yandex\.ru\/album\/([0-9]*)\/track\/([0-9]*)/,
116+
regex: /https?:\/\/music\.yandex\.ru\/track\/([0-9]*)(?:\?.*)?/,
117117
embedUrl: 'https://music.yandex.ru/iframe/#track/<%= remote_id %>/',
118118
html: '<iframe frameborder="0" style="border:none;width:540px;height:100px;" style="width:100%;" height="100"></iframe>',
119119
height: 100,
120120
width: 540,
121-
id: (ids) => ids.join('/'),
121+
id: (ids) => ids[0],
122122
},
123123
'yandex-music-playlist': {
124124
regex:

test/services.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,12 @@ describe('Services Regexps', () => {
270270

271271
const urls = [
272272
{
273-
source: 'https://music.yandex.ru/album/5643859/track/42662275',
274-
embed: 'https://music.yandex.ru/iframe/#track/5643859/42662275/',
273+
source: 'https://music.yandex.ru/track/49235718?utm_source=web&utm_medium=copy_link',
274+
embed: 'https://music.yandex.ru/iframe/#track/49235718/',
275275
},
276276
{
277-
source: 'https://music.yandex.ru/album/5393158/track/41249158',
278-
embed: 'https://music.yandex.ru/iframe/#track/5393158/41249158/',
277+
source: 'https://music.yandex.ru/track/42662275',
278+
embed: 'https://music.yandex.ru/iframe/#track/42662275/',
279279
},
280280
];
281281

@@ -496,10 +496,11 @@ describe('Services Regexps', () => {
496496
'twitch-video': 'https://www.twitch.tv/videos/315468440',
497497
'yandex-music-album': 'https://music.yandex.ru/album/5643859',
498498
'yandex-music-track':
499-
'https://music.yandex.ru/album/5643859/track/42662275',
499+
'https://music.yandex.ru/track/42662275',
500500
'yandex-music-playlist':
501501
'https://music.yandex.ru/users/yamusic-personal/playlists/25098905',
502502
codepen: 'https://codepen.io/Rikkokiri/pen/RYBrwG',
503+
503504
};
504505

505506
Object.entries(services).forEach(([name, url]) => {

0 commit comments

Comments
 (0)