lib/image_scraper/client.rb in rcarvalho-image_scraper-0.1.8.2 vs lib/image_scraper/client.rb in rcarvalho-image_scraper-0.1.8.3
- old
+ new
@@ -37,26 +37,25 @@
stylesheets.each do |stylesheet|
file = open(stylesheet) rescue next
css = file.string rescue IO.read(file) rescue next
images += css.scan(/url\((.*?)\)/).collect do |image_url|
- image_url = URI.escape image_url[0]
+ image_url = URI.escape ImageScraper::Util.cleanup_url(image_url[0])
image_url = image_url.gsub(/([{}|\^\[\]\@`])/) {|s| CGI.escape(s)} # escape characters that URI.escape doesn't get
if image_url.include?("data:image") and @include_css_data_images
image_url
else
- image_url = ImageScraper::Util.strip_quotes(image_url)
@convert_to_absolute_url ? ImageScraper::Util.absolute_url(stylesheet, image_url) : image_url
end
end
end
images
end
def stylesheets
return [] if doc.blank?
doc.xpath('//link[@rel="stylesheet"]').collect do |stylesheet|
- ImageScraper::Util.absolute_url url, URI.escape(stylesheet['href'])
+ ImageScraper::Util.absolute_url url, URI.escape(ImageScraper::Util.cleanup_url(stylesheet['href']))
end
end
end
end