From 025e35f6a1b9f6f80533805b89b7ab5962c89636 Mon Sep 17 00:00:00 2001 From: Adam Heath Date: Tue, 22 Mar 2016 17:34:36 +0800 Subject: [PATCH] Fix asset_hash with content rule and uncommented CSS url Fixes middleman/middleman#1852 --- middleman-core/features/asset_hash.feature | 7 +++++++ .../source/images/100px.jpg | Bin 0 -> 334 bytes .../source/stylesheets/test.css | 3 +++ middleman-core/lib/middleman-core/util/rack.rb | 2 +- 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 middleman-core/fixtures/asset-hash-minified-app/source/images/100px.jpg create mode 100644 middleman-core/fixtures/asset-hash-minified-app/source/stylesheets/test.css diff --git a/middleman-core/features/asset_hash.feature b/middleman-core/features/asset_hash.feature index dd659336..6a353370 100644 --- a/middleman-core/features/asset_hash.feature +++ b/middleman-core/features/asset_hash.feature @@ -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" diff --git a/middleman-core/fixtures/asset-hash-minified-app/source/images/100px.jpg b/middleman-core/fixtures/asset-hash-minified-app/source/images/100px.jpg new file mode 100644 index 0000000000000000000000000000000000000000..557d02781344edfba89f96b50e1315b9da17f061 GIT binary patch literal 334 zcmZ?wbh9u|Okqf2c+9|X=FFLC)240QxN**$Is5kQ+rEAK(W6IKty;Bs@nQySKnElU z(#yc|PvC^->b(}P&+h)8pwX9-IWJ??x}4Yh3UtnwWiY;2vf`)6K%U&&D2 z=)uHXBE-zZ&feMGE7{h;(ACp7&5NajjggI&nPJYn1wxE-mzB<*JAdKoC7!dYN;Ynp z%*M=7vuXF%rpX=~_Z`|R%*x0ra&YgF4XfD7)}CL_z|J^f_r(i~E_fYloI2rw@SJ-` z=T3jv@4c*}xvD{!k%NI_@|*X&-WC4-^Y`C>24*f9j|~eBHggDT#hlo%@Nm0;vez7s Zjf;+UOBiR}Ik9o^@qQKsT^9xhYXBQ`m0bV; literal 0 HcmV?d00001 diff --git a/middleman-core/fixtures/asset-hash-minified-app/source/stylesheets/test.css b/middleman-core/fixtures/asset-hash-minified-app/source/stylesheets/test.css new file mode 100644 index 00000000..059fce9a --- /dev/null +++ b/middleman-core/fixtures/asset-hash-minified-app/source/stylesheets/test.css @@ -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)} diff --git a/middleman-core/lib/middleman-core/util/rack.rb b/middleman-core/lib/middleman-core/util/rack.rb index 17ac7252..f8003efe 100644 --- a/middleman-core/lib/middleman-core/util/rack.rb +++ b/middleman-core/lib/middleman-core/util/rack.rb @@ -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('