Merge pull request #1514 from cfstras/youtube-https

YoutubeOnebox: FIX HTTP-specific URLs
This commit is contained in:
Neil Lalonde 2013-10-09 12:33:49 -07:00
commit 43fc772a53
2 changed files with 10 additions and 0 deletions

View File

@ -32,6 +32,11 @@ module Oneboxer
URI.escape(val, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
end
# Replace any occurence of a HTTP or HTTPS URL in the string with the protocol-agnostic variant
def replace_agnostic(var)
var.gsub! /https?:\/\//, '//' if var.is_a? String
end
end
def initialize(url, opts={})

View File

@ -6,5 +6,10 @@ module Oneboxer
def oembed_endpoint
"http://www.youtube.com/oembed?url=#{BaseOnebox.uriencode(@url.sub('https://', 'http://'))}&format=json"
end
def onebox
# Youtube allows HTTP and HTTPS, so replace them with the protocol-agnostic variant
super.each { |entry| BaseOnebox.replace_agnostic entry }
end
end
end