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-177: dont embed kick vods and clips #315

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
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