diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9dbaf49fd..43ea75037 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -152,7 +152,7 @@ module ApplicationHelper end if options[:youtube] - while youtube = message.match(/youtube\.com::([A-Za-z0-9_\\]+)/) + while youtube = message.match(/youtube\.com::([A-Za-z0-9_\\\-]+)/) videoid = youtube[1] message.gsub!('youtube.com::'+videoid, 'Youtube: ' + youtube_title(videoid) + '') end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index b58357193..8938dfd3d 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -84,6 +84,19 @@ describe ApplicationHelper do res.should =~ /data-host="youtube.com"/ res.should =~ /data-video-id="#{videoid}"/ end + + it "recognizes youtube links with hyphens" do + proto="http" + videoid = "ABYnqp-bxvg" + url="www.youtube.com/watch?v="+videoid+"&a=GxdCwVVULXdvEBKmx_f5ywvZ0zZHHHDU&list=ML&playnext=1" + title = "UP & down & UP & down &" + mock_http = mock("http") + Net::HTTP.stub!(:new).with('gdata.youtube.com', 80).and_return(mock_http) + mock_http.should_receive(:get).with('/feeds/api/videos/'+videoid+'?v=2', nil).and_return([nil, 'Foobar