mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
YoutubeOnebox: FIX HTTP-specific URLs
by replacing with protocol-agnostic URLs. This fixes the mixed-content warning for secure instances of discourse, at least for Youtube
This commit is contained in:
parent
c48030f1ef
commit
109c10c883
2 changed files with 10 additions and 0 deletions
|
@ -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 a new issue