Skip to content

Commit

Permalink
fixing again the absolute url...
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebini committed Apr 30, 2010
1 parent 5d3a738 commit 21dbf87
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/mail_style/inline_styles.rb
Expand Up @@ -139,18 +139,21 @@ def update_image_urls(style)
style
end

# Absolutize URL (Absolutize? Seriously?)
# Absolutize URL (Absolutize? Seriously?)
def absolutize_url(url, base_path = '')
original_url = url

unless original_url[URI::regexp(%w[http https])]
host = default_url_options[:host]
protocol = default_url_options[:protocol]
protocol = "http://" if protocol.blank?
protocol+= "://" unless protocol.include?("://")

url = URI.join(host, base_path, original_url).to_s
url = protocol+url unless url.include?(protocol)
host = default_url_options[:host]

[host,protocol].each{|r| original_url.gsub!(r,"") }
host = protocol+host unless host[URI::regexp(%w[http https])]

url = URI.join host, base_path, original_url
end

url.to_s
Expand Down

0 comments on commit 21dbf87

Please sign in to comment.