lib/onebox/engine/standard_embed.rb in onebox-1.4.3 vs lib/onebox/engine/standard_embed.rb in onebox-1.4.4

- old
+ new

@@ -59,14 +59,17 @@ end og end - def fetch_response(location, limit = 3) + def fetch_response(location, limit = 5, domain = nil) raise Net::HTTPError.new('HTTP redirect too deep', location) if limit == 0 uri = URI(location) + if !uri.host + uri = URI("#{domain}#{location}") + end http = Net::HTTP.new(uri.host, uri.port) http.open_timeout = Onebox.options.connect_timeout http.read_timeout = Onebox.options.timeout if uri.is_a?(URI::HTTPS) http.use_ssl = true @@ -74,10 +77,10 @@ end response = http.request_get(uri.request_uri) case response when Net::HTTPSuccess then response - when Net::HTTPRedirection then fetch_response(response['location'], limit - 1) + when Net::HTTPRedirection then fetch_response(response['location'], limit - 1, "#{uri.scheme}://#{uri.host}") else response.error! end end