Fix asset_hash with content rule and uncommented CSS url

Fixes middleman/middleman#1852
This commit is contained in:
Adam Heath 2016-03-22 17:34:36 +08:00
parent 0df7f0d6ac
commit 025e35f6a1
4 changed files with 11 additions and 1 deletions

View file

@ -283,8 +283,15 @@ Feature: Assets get file hashes appended to them and references to them are upda
When I cd to "build"
Then the following files should exist:
| javascripts/jquery.min-276c87ff.js |
| stylesheets/test-7de2ad06.css |
And the following files should not exist:
| javascripts/jquery.min.js |
And the file "stylesheets/test-7de2ad06.css" should contain:
"""
.no-bug{background-image:url(/images/100px-5fd6fb90.jpg)}
.bug{content:"";background-image:url(/images/100px-5fd6fb90.jpg)}
.no-bug{content:""; background-image:url(/images/100px-5fd6fb90.jpg)}
"""
Scenario: Source map paths include the hash
Given a successfully built app at "asset-hash-source-map"

Binary file not shown.

After

Width:  |  Height:  |  Size: 334 B

View file

@ -0,0 +1,3 @@
.no-bug{background-image:url(/images/100px.jpg)}
.bug{content:"";background-image:url(/images/100px.jpg)}
.no-bug{content:""; background-image:url(/images/100px.jpg)}

View file

@ -22,7 +22,7 @@ module Middleman
Contract String, String, ArrayOf[String], Proc => String
def rewrite_paths(body, _path, exts, &_block)
matcher = /([\'\"\(,]\s*|# sourceMappingURL=)([^\s\'\"\)>]+(#{::Regexp.union(exts)}))/
matcher = /([\'\"\(,]\s*|# sourceMappingURL=)([^\s\'\"\)\(>]+(#{::Regexp.union(exts)}))/
url_fn_prefix = 'url('