diff --git a/assets/chat/js/hashlinkconverter.js b/assets/chat/js/hashlinkconverter.js index 65a14b84..ab0f0bc7 100644 --- a/assets/chat/js/hashlinkconverter.js +++ b/assets/chat/js/hashlinkconverter.js @@ -7,8 +7,7 @@ const MISSING_VIDEO_ID_ERROR = 'Invalid Youtube link - Missing video id'; class HashLinkConverter { constructor() { this.hasHttp = /^http[s]?:\/{0,2}/; - this.youtubeLiveRegex = /^live\/([A-Za-z0-9-_]{11})$/; - this.youtubeShortsRegex = /^shorts\/([A-Za-z0-9-_]{11})$/; + this.youtubeRegex = /^(?:shorts|live|embed)\/([A-Za-z0-9-_]{11})$/; this.twitchClipRegex = /^[^/]+\/clip\/([A-Za-z0-9-_]*)$/; this.twitchVODRegex = /^videos\/(\d+)$/; this.rumbleEmbedRegex = /^embed\/([a-z0-9]+)\/?$/; @@ -42,11 +41,7 @@ class HashLinkConverter { return `#twitch-clip/${pathname}`; case 'www.youtube.com': case 'youtube.com': - match = pathname.match(this.youtubeLiveRegex); - if (match) { - return `#youtube/${match[1]}`; - } - match = pathname.match(this.youtubeShortsRegex); + match = pathname.match(this.youtubeRegex); if (match) { return `#youtube/${match[1]}`; } diff --git a/assets/chat/js/hashlinkconverter.test.js b/assets/chat/js/hashlinkconverter.test.js index a3776e6b..1d5c9c94 100644 --- a/assets/chat/js/hashlinkconverter.test.js +++ b/assets/chat/js/hashlinkconverter.test.js @@ -59,6 +59,11 @@ describe('Valid embeds', () => { 'https://youtube.com/shorts/Bg1JpTqc0iA?si=7pzY1RnY2fEe9A8_', '#youtube/Bg1JpTqc0iA', ], + [ + 'Youtube embed link', + 'https://www.youtube.com/embed/Akala8bkIu8', + '#youtube/Akala8bkIu8', + ], [ 'Rumble embed', 'https://rumble.com/embed/v26pcdc/?pub=4',