From f708da1240c5303a05b64c51bcd9cbedf04d9007 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Sun, 8 Jun 2014 01:16:08 -0700 Subject: [PATCH] fix youtube start time, make youtube embedding more robust against garbage appended to URLs --- src/Linkification/Linkify.coffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index a7e816d15..9025d0584 100755 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -386,10 +386,11 @@ Linkify = src: "https://vine.co/#{a.dataset.uid}/card" , key: 'YouTube' - regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([^#\&\?]*)\??(t\=.*)?/ + regExp: /.*(?:youtu.be\/|youtube.*v=|youtube.*\/embed\/|youtube.*\/v\/|youtube.*videos\/)([\w-]{11})[^#\&\?]?(.*)/ el: (a) -> + start = a.dataset.options.match /\b(?:star)?t\=(\w+)/ el = $.el 'iframe', - src: "//www.youtube.com/embed/#{a.dataset.uid}#{if a.dataset.option then '#' + a.dataset.option else ''}?wmode=opaque" + src: "//www.youtube.com/embed/#{a.dataset.uid}?wmode=opaque#{if start then '&start=' + start[1] else ''}" el.setAttribute "allowfullscreen", "true" el title: