Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DES-178: add youtube shorts embed support #316

Merged
merged 2 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions assets/chat/js/hashlinkconverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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.twitchClipRegex = /^[^/]+\/clip\/([A-Za-z0-9-_]*)$/;
this.twitchVODRegex = /^videos\/(\d+)$/;
this.rumbleEmbedRegex = /^embed\/([a-z0-9]+)\/?$/;
Expand Down Expand Up @@ -45,6 +46,10 @@ class HashLinkConverter {
if (match) {
return `#youtube/${match[1]}`;
}
match = pathname.match(this.youtubeShortsRegex);
if (match) {
return `#youtube/${match[1]}`;
}
videoId = url.searchParams.get('v');
timestamp = url.searchParams.get('t');
if (!videoId) {
Expand Down
5 changes: 5 additions & 0 deletions assets/chat/js/hashlinkconverter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ describe('Valid embeds', () => {
'https://www.youtube.com/live/EHs-_2ddcUQ?feature=share',
'#youtube/EHs-_2ddcUQ',
],
[
'Youtube shorts link',
'https://youtube.com/shorts/Bg1JpTqc0iA?si=7pzY1RnY2fEe9A8_',
'#youtube/Bg1JpTqc0iA',
],
[
'Rumble embed',
'https://rumble.com/embed/v26pcdc/?pub=4',
Expand Down