lib/link_thumbnailer/fetcher.rb in link_thumbnailer-1.0.8 vs lib/link_thumbnailer/fetcher.rb in link_thumbnailer-1.0.9
- old
+ new
@@ -19,10 +19,12 @@
http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless LinkThumbnailer.configuration.verify_ssl
http.open_timeout = LinkThumbnailer.configuration.http_timeout
resp = http.request(self.url)
case resp
when Net::HTTPSuccess then resp.body
- when Net::HTTPRedirection then fetch(resp['location'], redirect_count + 1)
+ when Net::HTTPRedirection
+ location = resp['location'].start_with?('http') ? resp['location'] : "#{self.url.scheme}://#{self.url.host}#{resp['location']}"
+ fetch(location, redirect_count + 1)
else resp.error!
end
end
end