lib/jammit/compressor.rb in jammit-0.2.8 vs lib/jammit/compressor.rb in jammit-0.2.9

- old
+ new

@@ -90,12 +90,13 @@ # location of the original stylesheet path. Validate the images while we're # at it. def concatenate_and_tag_images(paths, variant=nil) stylesheets = [paths].flatten.map do |css_path| File.read(css_path).gsub(IMAGE_DETECTOR) do |url| - new_path = rewrite_image_path(Pathname.new($1), Pathname.new(File.expand_path(css_path)), !!variant) - "url(#{new_path})" + ipath, cpath = Pathname.new($1), Pathname.new(File.expand_path(css_path)) + is_url = URI.parse($1).absolute? + is_url ? url : "url(#{rewrite_image_path(ipath, cpath, !!variant)})" end end stylesheets.join("\n") end @@ -127,10 +128,10 @@ # be tagged for embedding if embeddable, and referenced at the correct level # if relative. def rewrite_image_path(image_path, css_path, embed=false) public_path = absolute_path(image_path, css_path) return "__EMBED__#{public_path}" if embed && embeddable?(public_path) - image_path.relative? ? relative_path(public_path) : image_path.to_s + image_path.absolute? ? image_path.to_s : relative_path(public_path) end # Get the site-absolute public path for an image file path that may or may # not be relative, given the path of the stylesheet that contains it. def absolute_path(image_pathname, css_pathname)