Sha256: 73ff23ebf7da4314a5519c1d176a942e2d0a191cef0632598dce426806979432
Contents?: true
Size: 1.04 KB
Versions: 4
Compression:
Stored size: 1.04 KB
Contents
class Premailer module Rails module CSSLoaders module NetworkLoader extend self def load(url) uri = uri_for_url(url) Net::HTTP.get(uri) if uri end def uri_for_url(url) uri = URI(url) if uri.host.present? return uri if uri.scheme.present? URI("http://#{uri.to_s}") elsif asset_host_present? scheme, host = asset_host.split(%r{:?//}) scheme, host = host, scheme if host.nil? scheme = 'http' if scheme.blank? path = url URI(File.join("#{scheme}://#{host}", path)) end end def valid_uri?(uri) uri.host.present? && uri.scheme.present? end def asset_host_present? ::Rails.configuration.action_controller.asset_host.present? end def asset_host config = ::Rails.configuration.action_controller.asset_host config.respond_to?(:call) ? config.call : config end end end end end
Version data entries
4 entries across 4 versions & 2 rubygems