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
This commit is contained in:
WastedMeerkat 2021-10-20 17:58:04 -05:00 committed by GitHub
parent c298856c70
commit 38087bd3f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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}"