Skip to content

Commit

Permalink
Hashlink regex fix (#267)
Browse files Browse the repository at this point in the history
* Fixed YT live and Twitch clip regexes

* Added test for - and _ for YT live links
  • Loading branch information
Fritz-02 authored May 29, 2023
1 parent 8787710 commit b3c36d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions assets/chat/js/hashlinkconverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ 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.twitchClipRegex = /^[^/]+\/clip\/([a-zA-z0-9-]*)$/;
this.youtubeLiveRegex = /^live\/([A-Za-z0-9-_]{11})$/;
this.twitchClipRegex = /^[^/]+\/clip\/([A-Za-z0-9-_]*)$/;
this.twitchVODRegex = /^videos\/(\d+)$/;
this.rumbleEmbedRegex = /^embed\/([a-z0-9]+)\/?$/;
}
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 @@ -39,6 +39,11 @@ describe('Valid embeds', () => {
'https://www.youtube.com/live/jfKfPfyJRdk?feature=share',
'#youtube/jfKfPfyJRdk',
],
[
'Youtube live stream shareable link - and _',
'https://www.youtube.com/live/EHs-_2ddcUQ?feature=share',
'#youtube/EHs-_2ddcUQ',
],
[
'Rumble embed',
'https://rumble.com/embed/v26pcdc/?pub=4',
Expand Down

0 comments on commit b3c36d3

Please sign in to comment.