lib/onebox/helpers.rb in onebox-1.8.67 vs lib/onebox/helpers.rb in onebox-1.8.68
- old
+ new
@@ -185,7 +185,21 @@
url.gsub!('"', """)
url.gsub!(/[^\w\-`.~:\/?#\[\]@!$&'\(\)*+,;=%]/, "")
url
end
+ def self.get_absolute_image_url(src, url)
+ if src && !!(src =~ /^\/\//)
+ uri = URI(url)
+ src = "#{uri.scheme}:#{src}"
+ elsif src && src.match(/^https?:\/\//i).nil?
+ uri = URI(url)
+ src = if !src.start_with?("/") && uri.path.present?
+ "#{uri.scheme}://#{uri.host.sub(/\/$/, '')}#{uri.path.sub(/\/$/, '')}/#{src.sub(/^\//, '')}"
+ else
+ "#{uri.scheme}://#{uri.host.sub(/\/$/, '')}/#{src.sub(/^\//, '')}"
+ end
+ end
+ src
+ end
end
end