mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-18 03:25:31 -05:00
109c10c883
by replacing with protocol-agnostic URLs. This fixes the mixed-content warning for secure instances of discourse, at least for Youtube
15 lines
496 B
Ruby
15 lines
496 B
Ruby
require_dependency 'oneboxer/oembed_onebox'
|
|
|
|
module Oneboxer
|
|
class YoutubeOnebox < OembedOnebox
|
|
matcher /^https?:\/\/(?:www\.)?(?:youtube\.com|youtu\.be)\/.+$/
|
|
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
|