diff --git a/app/helpers/markdownify_helper.rb b/app/helpers/markdownify_helper.rb index 3fffdda30..4e0244375 100644 --- a/app/helpers/markdownify_helper.rb +++ b/app/helpers/markdownify_helper.rb @@ -97,7 +97,7 @@ module MarkdownifyHelper end def process_vimeo(message, vimeo_maps) - regex = /https?:\/\/(?:w{3}\.)?vimeo.com\/(\d{6,})/ + regex = /https?:\/\/(?:w{3}\.)?vimeo.com\/(\d{6,})\/?/ processed_message = message.gsub(regex) do |matched_string| match_data = message.match(regex) video_id = match_data[1] @@ -131,4 +131,4 @@ module MarkdownifyHelper end message end -end \ No newline at end of file +end diff --git a/spec/helpers/markdownify_helper_spec.rb b/spec/helpers/markdownify_helper_spec.rb index e292490d4..6e9746d68 100644 --- a/spec/helpers/markdownify_helper_spec.rb +++ b/spec/helpers/markdownify_helper_spec.rb @@ -44,6 +44,15 @@ describe MarkdownifyHelper do res.should =~ /data-video-id="#{video_id}"/ end + it "matches a trailing slash in a vimeo link" do + video_id = "17449557" + url = "http://www.vimeo.com/#{video_id}/" + res = markdownify(url) + res.should =~ /data-host="vimeo.com"/ + res.should =~ /data-video-id="#{video_id}"/ + res.should_not =~ />\// + end + it "recognizes youtube links" do video_id = "0x__dDWdf23" url = "http://www.youtube.com/watch?v=" + video_id + "&a=GxdCwVVULXdvEBKmx_f5ywvZ0zZHHHDU&list=ML&playnext=1" @@ -236,4 +245,4 @@ describe MarkdownifyHelper do end end end -end \ No newline at end of file +end