Skip to content
Extraits de code Groupes Projets
Valider 502f4670 rédigé par MrZYX's avatar MrZYX
Parcourir les fichiers

fix youtu.be links

parent 42f5f7fc
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -70,7 +70,7 @@ module MarkdownifyHelper
captures = [$1,$2,$3]
if !captures[0].nil?
m
elsif m.match(/(youtube|vimeo)/)
elsif m.match(/(youtu.?be|vimeo)/)
m.gsub(/(\*|_)/) { |m| "\\#{$1}" } #remove markers on markdown chars to not markdown inside links
else
res = %{<a target="_blank" href="#{captures[1]}://#{captures[2]}">#{captures[2]}</a>}
......
......@@ -35,6 +35,15 @@ describe MarkdownifyHelper do
markdownify(proto+"://"+url).should == "<a target=\"_blank\" href=\""+proto+"://"+url+"\">"+url+"</a>"
end
it "doesn't double parse video links" do
message = "http://www.vimeo.com/17449557
http://www.youtube.com/watch?v=0x__dDWdf23&a=GxdCwVVULXdvEBKmx_f5ywvZ0zZHHHDU&list=ML&playnext=1
http://youtu.be/x_CzD0GBD-4"
res = markdownify(message)
res.should =~ /href.+href.+href/
res.should_not =~ /href.+href.+href.+href/
end
describe "video links" do
it "recognizes vimeo links" do
video_id = "17449557"
......@@ -62,6 +71,15 @@ describe MarkdownifyHelper do
res.should =~ /data-video-id="#{video_id}"/
end
it "recognizes youtu.be links" do
video_id = "x_CzD0GBD-4"
url = "http://youtu.be/#{video_id}"
res = markdownify(url)
res.should =~ /Youtube:/
res.should =~ /data-host="youtube.com"/
res.should =~ /data-video-id="#{video_id}"/
end
it "recognizes youtube links with hyphens" do
video_id = "ABYnqp-bxvg"
url = "http://www.youtube.com/watch?v=" + video_id + "&a=GxdCwVVULXdvEBKmx_f5ywvZ0zZHHHDU&list=ML&playnext=1"
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter