Skip to content

Commit

Permalink
fix: dont embed kick vods and clips (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
vyneer authored Sep 6, 2023
1 parent fcec616 commit 6b8b2d2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions assets/chat/js/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,7 @@ class Chat {
} catch (error) {
MessageBuilder.error(error.message).into(this);
MessageBuilder.info(
'Usage: /embed <link> OR /e <link> (Valid links: Twitch streams, VODs, clips, Youtube, Rumble)',
'Usage: /embed <link> OR /e <link> (Valid links: Twitch streams, VODs, clips, Youtube, Rumble, Kick streams)',
).into(this);
}
}
Expand All @@ -1878,7 +1878,7 @@ class Chat {
MessageBuilder.error(error.message).into(this);
}
MessageBuilder.info(
'Usage: /postembed [<link>] [<message>] (Alias: /pe) (Valid links: Twitch streams, VODs, clips, Youtube, Rumble)',
'Usage: /postembed [<link>] [<message>] (Alias: /pe) (Valid links: Twitch streams, VODs, clips, Youtube, Rumble, Kick streams)',
).into(this);
}
}
Expand Down
3 changes: 3 additions & 0 deletions assets/chat/js/hashlinkconverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class HashLinkConverter {
throw new Error(RUMBLE_EMBED_ERROR);
case 'www.kick.com':
case 'kick.com':
if (url.searchParams.has('clip') || pathname.startsWith('video/')) {
throw new Error(INVALID_LINK_ERROR);
}
return `#kick/${pathname}`;
default:
throw new Error(INVALID_LINK_ERROR);
Expand Down
11 changes: 11 additions & 0 deletions assets/chat/js/hashlinkconverter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe('Valid embeds', () => {
'https://rumble.com/embed/v26pcdc/?pub=4',
'#rumble/v26pcdc',
],
['Kick stream link', 'https://kick.com/destiny', '#kick/destiny'],
])('%s', (_, url, expectedHashLink) => {
const hlc = new HashLinkConverter();
expect(hlc.convert(url)).toBe(expectedHashLink);
Expand All @@ -83,6 +84,16 @@ describe('Invalid embeds', () => {
'https://www.youtube.com/tZ_gn0E87Qo',
MISSING_VIDEO_ID_ERROR,
],
[
'Kick VOD link',
'https://kick.com/video/d353657d-f6c5-40c0-9df2-645aadda1e66',
INVALID_LINK_ERROR,
],
[
'Kick clip link',
'https://kick.com/destiny?clip=clip_01H96SPCHRV0E2X8Y670CGXTS4',
INVALID_LINK_ERROR,
],
[
'No arguments were giving after the command',
undefined,
Expand Down

0 comments on commit 6b8b2d2

Please sign in to comment.