mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 15:05:24 +08:00
Merge pull request #1514 from cfstras/youtube-https
YoutubeOnebox: FIX HTTP-specific URLs
This commit is contained in:
commit
43fc772a53
|
@ -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={})
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user