Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding https support for vimeo videos.

  • Loading branch information...
commit 6a8fbdd20d82cc93f8e8096d035124f6e359a59f 1 parent c5425f3
Amit Gaur websymphony authored
7 lib/auto_html/filters/vimeo.rb
View
@@ -1,6 +1,7 @@
AutoHtml.add_filter(:vimeo).with(:width => 440, :height => 248, :show_title => false, :show_byline => false, :show_portrait => false) do |text, options|
- text.gsub(/http:\/\/(www.)?vimeo\.com\/([A-Za-z0-9._%-]*)((\?|#)\S+)?/) do
- vimeo_id = $2
+ text.gsub(/(https?):\/\/(www.)?vimeo\.com\/([A-Za-z0-9._%-]*)((\?|#)\S+)?/) do
+ protocol = $1
+ vimeo_id = $3
width = options[:width]
height = options[:height]
show_title = "title=0" unless options[:show_title]
@@ -10,6 +11,6 @@
query_string_variables = [show_title, show_byline, show_portrait].compact.join("&")
query_string = "?" + query_string_variables unless query_string_variables.empty?
- %{<iframe src="http://player.vimeo.com/video/#{vimeo_id}#{query_string}" width="#{width}" height="#{height}" frameborder="#{frameborder}"></iframe>}
+ %{<iframe src="#{protocol}://player.vimeo.com/video/#{vimeo_id}#{query_string}" width="#{width}" height="#{height}" frameborder="#{frameborder}"></iframe>}
end
end
5 test/unit/filters/vimeo_test.rb
View
@@ -41,5 +41,10 @@ def test_transform_with_portrait
result = auto_html("http://www.vimeo.com/3300155") { vimeo(:width => 300, :height => 250, :show_portrait => true) }
assert_equal '<iframe src="http://player.vimeo.com/video/3300155?title=0&byline=0" width="300" height="250" frameborder="0"></iframe>', result
end
+
+ def test_transform_url_with_https
+ result = auto_html('https://vimeo.com/3300155') { vimeo }
+ assert_equal '<iframe src="https://player.vimeo.com/video/3300155?title=0&byline=0&portrait=0" width="440" height="248" frameborder="0"></iframe>', result
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.