From 38087bd3f7d304f5d3737e3be4513e7ecd37ed2f Mon Sep 17 00:00:00 2001 From: WastedMeerkat Date: Wed, 20 Oct 2021 17:58:04 -0500 Subject: [PATCH] Accomodate mobile Twitch links m.twitch.tv subdomain links now work, mobile clip links are a bit different so had to rework the regex again --- src/Linkification/Embedding.coffee | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Linkification/Embedding.coffee b/src/Linkification/Embedding.coffee index eaddffc3c..f220c73d2 100644 --- a/src/Linkification/Embedding.coffee +++ b/src/Linkification/Embedding.coffee @@ -422,10 +422,11 @@ Embedding = text: (_) -> _.title , key: 'TwitchTV' - regExp: /^\w+:\/\/(?:www\.|secure\.|clips\.)?twitch\.tv\/(\w[^#\&\?]*)/ + regExp: /^\w+:\/\/(?:www\.|secure\.|clips\.|m\.)?twitch\.tv\/(\w[^#\&\?]*)/ el: (a) -> - if a.dataset.href.match(/^\w+:\/\/(?:(clips\.)|\w+\.)?twitch\.tv/)[1] - url = "//clips.twitch.tv/embed?clip=#{a.dataset.uid}&parent=#{location.hostname}" + m = a.dataset.href.match /^\w+:\/\/(?:(clips\.)|\w+\.)?twitch\.tv\/(clip\/)?(\w[^#\&\?]*)/; + if m[1] or m[2] + url = "//clips.twitch.tv/embed?clip=#{m[3]}&parent=#{location.hostname}" else m = a.dataset.uid.match /(\w+)(?:\/(?:v\/)?(\d+))?/ url = "//player.twitch.tv/?#{if m[2] then "video=v#{m[2]}" else "channel=#{m[1]}"}&autoplay=false&parent=#{location.hostname}"