FIX: discourse local onebox not working correctly in multisite

This commit is contained in:
Sam 2016-04-13 12:18:46 +10:00
parent 4ceb04517f
commit 6688dce2b8

View File

@ -3,7 +3,10 @@ module Onebox
class DiscourseLocalOnebox class DiscourseLocalOnebox
include Engine include Engine
matches_regexp Regexp.new("^#{Discourse.base_url.gsub(".","\\.")}.*$", true) # we need to allow for multisite here
def self.is_on_site?(url)
Regexp.new("^#{Discourse.base_url.gsub(".","\\.")}.*$", true) === url.to_s
end
# Use this onebox before others # Use this onebox before others
def self.priority def self.priority
@ -17,10 +20,10 @@ module Onebox
route = Rails.application.routes.recognize_path(uri.path.sub(Discourse.base_uri, "")) route = Rails.application.routes.recognize_path(uri.path.sub(Discourse.base_uri, ""))
case route[:controller] case route[:controller]
when 'uploads' when 'uploads'
super is_on_site?(other)
when 'topics' when 'topics'
# super will use matches_regexp to match the domain name # super will use matches_regexp to match the domain name
super is_on_site?(other)
else else
false false
end end
@ -28,7 +31,7 @@ module Onebox
false false
end end
else else
super is_on_site?(other)
end end
end end