lib/onebox/engine/stack_exchange_onebox.rb in onebox-1.5.21 vs lib/onebox/engine/stack_exchange_onebox.rb in onebox-1.5.22
- old
+ new
@@ -7,20 +7,24 @@
def self.domains
%w(stackexchange stackoverflow superuser serverfault askubuntu)
end
- matches_regexp /^http:\/\/(?:(?:(?<subsubdomain>\w*)\.)?(?<subdomain>\w*)\.)?(?<domain>#{domains.join('|')})\.com\/(?:questions|q)\/(?<question>\d*)/
+ matches_regexp /^https?:\/\/(?:(?:(?<subsubdomain>\w*)\.)?(?<subdomain>\w*)\.)?(?<domain>#{domains.join('|')})\.com\/(?:questions|q)\/(?<question>\d*)/
+ def always_https?
+ uri.host.split('.').length <= 3
+ end
+
private
def match
@match ||= @url.match(@@matcher)
end
def url
domain = URI(@url).host
- "http://api.stackexchange.com/2.1/questions/#{match[:question]}?site=#{domain}"
+ "https://api.stackexchange.com/2.1/questions/#{match[:question]}?site=#{domain}"
end
def data
return @data if @data