lib/sprockets/rails/asset_url_processor.rb in sprockets-rails-3.4.0 vs lib/sprockets/rails/asset_url_processor.rb in sprockets-rails-3.4.1
- old
+ new
@@ -1,15 +1,17 @@
module Sprockets
module Rails
# Rewrites urls in CSS files with the digested paths
class AssetUrlProcessor
- REGEX = /url\(\s*["']?(?!(?:\#|data|http))([^"'\s)]+)\s*["']?\)/
-
+ REGEX = /url\(\s*["']?(?!(?:\#|data|http))(?<relativeToCurrentDir>.\/)?(?<path>[^"'\s)]+)\s*["']?\)/
def self.call(input)
context = input[:environment].context_class.new(input)
- data = input[:data].gsub(REGEX) { |_match| "url(#{context.asset_path($1)})" }
+ data = input[:data].gsub(REGEX) do |_match|
+ path = Regexp.last_match[:path]
+ "url(#{context.asset_path(path)})"
+ end
- { data: data }
+ context.metadata.merge(data: data)
end
end
end
end