adamburmister / morning_glory

Manage deployments of Rails assets to the Amazon S3/Cloudfront CDN
MIT License
32 stars 12 forks source link

RAILS_ASSET_ID inserted before quotation in CSS image ref replacement #2

Closed jgarber closed 14 years ago

jgarber commented 14 years ago
REGEX_ROOT_RELATIVE_CSS_URL = /url\((\'|\")?(\/+.*(#{CONTENT_TYPES.keys.map { |k| '\.' + k.to_s }.join('|')}))\1?\)/
buffer = File.new(file,'r').read.gsub(REGEX_ROOT_RELATIVE_CSS_URL) { |m| m.insert m.index('(') + 1, '/'+ENV['RAILS_ASSET_ID'] }

Rewrites url references with quotes like: background: url(/REV_20100415043157'/images/app/fancybox/fancy_closebox.png') (example from jQuery Fancybox)

I'm working on a fix and will send you a pull request. Thanks.

adamburmister commented 14 years ago

Awesome, thanks for that.

adamburmister commented 14 years ago

Suggestion: buffer = File.new(file,'r').read.gsub(REGEX_ROOT_RELATIVE_CSS_URL, "url(\1#{ENV['RAILS_ASSET_ID']}\2\1)")

I need to add some test cases for this.

adamburmister commented 14 years ago

Oops, I think I missed a '/' root: "url(\1/#{ENV['RAILS_ASSET_ID']}\2\1)"

adamburmister commented 14 years ago

Pulled