Skip to content

Commit

Permalink
Modify the regex to keep the matching clean
Browse files Browse the repository at this point in the history
  • Loading branch information
reda777 committed May 21, 2024
1 parent 3e85e1e commit b671cfa
Showing 1 changed file with 2 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,7 +7,7 @@ const MISSING_VIDEO_ID_ERROR = 'Invalid Youtube link - Missing video id';
class HashLinkConverter {
constructor() {
this.hasHttp = /^http[s]?:\/{0,2}/;
this.youtubeRegex = /^(shorts|live|embed)\/([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]+)\/?$/;
Expand Down Expand Up @@ -43,7 +43,7 @@ class HashLinkConverter {
case 'youtube.com':
match = pathname.match(this.youtubeRegex);
if (match) {
return `#youtube/${match[2]}`;
return `#youtube/${match[1]}`;
}
videoId = url.searchParams.get('v');
timestamp = url.searchParams.get('t');
Expand Down

0 comments on commit b671cfa

Please sign in to comment.