diff --git a/middleman-core/features/asset_hash.feature b/middleman-core/features/asset_hash.feature index a6462098..e8a6ace5 100644 --- a/middleman-core/features/asset_hash.feature +++ b/middleman-core/features/asset_hash.feature @@ -8,6 +8,8 @@ Feature: Assets get a file hash appended to their and references to them are upd | favicon.ico | | images/100px-1242c368.png | | images/100px-5fd6fb90.jpg | + | images/200px-c11eb203.jpg | + | images/300px-59adce76.jpg | | images/100px-5fd6fb90.gif | | javascripts/application-1d8d5276.js | | stylesheets/site-50eaa978.css | @@ -29,6 +31,9 @@ Feature: Assets get a file hash appended to their and references to them are upd And the file "index.html" should contain 'href="stylesheets/site-50eaa978.css"' And the file "index.html" should contain 'src="javascripts/application-1d8d5276.js"' And the file "index.html" should contain 'src="images/100px-5fd6fb90.jpg"' + And the file "index.html" should contain 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"' + And the file "index.html" should contain 'src="images/100px-5fd6fb90.gif"' + And the file "index.html" should contain 'src="images/100px-1242c368.png"' And the file "subdir/index.html" should contain 'href="../stylesheets/site-50eaa978.css"' And the file "subdir/index.html" should contain 'src="../javascripts/application-1d8d5276.js"' And the file "subdir/index.html" should contain 'src="../images/100px-5fd6fb90.jpg"' @@ -49,6 +54,7 @@ Feature: Assets get a file hash appended to their and references to them are upd And I should see 'href="stylesheets/site-50eaa978.css"' And I should see 'src="javascripts/application-1d8d5276.js"' And I should see 'src="images/100px-5fd6fb90.jpg"' + And I should see 'srcset="images/100px-5fd6fb90.jpg 1x, images/200px-c11eb203.jpg 2x, images/300px-59adce76.jpg 3x"' When I go to "/subdir/" Then I should see 'href="../stylesheets/site-50eaa978.css"' And I should see 'src="../javascripts/application-1d8d5276.js"' diff --git a/middleman-core/fixtures/asset-hash-app/source/images/200px.jpg b/middleman-core/fixtures/asset-hash-app/source/images/200px.jpg new file mode 100644 index 00000000..1a236747 Binary files /dev/null and b/middleman-core/fixtures/asset-hash-app/source/images/200px.jpg differ diff --git a/middleman-core/fixtures/asset-hash-app/source/images/300px.jpg b/middleman-core/fixtures/asset-hash-app/source/images/300px.jpg new file mode 100644 index 00000000..5a1d9e03 Binary files /dev/null and b/middleman-core/fixtures/asset-hash-app/source/images/300px.jpg differ diff --git a/middleman-core/fixtures/asset-hash-app/source/index.html.erb b/middleman-core/fixtures/asset-hash-app/source/index.html.erb index fe58ad66..59a9c54f 100644 --- a/middleman-core/fixtures/asset-hash-app/source/index.html.erb +++ b/middleman-core/fixtures/asset-hash-app/source/index.html.erb @@ -3,7 +3,7 @@ <% end %>

Image url:

- +

Ignored path:

diff --git a/middleman-core/lib/middleman-more/extensions/asset_hash.rb b/middleman-core/lib/middleman-more/extensions/asset_hash.rb index ae5bd0fc..2384eacb 100644 --- a/middleman-core/lib/middleman-more/extensions/asset_hash.rb +++ b/middleman-core/lib/middleman-more/extensions/asset_hash.rb @@ -91,7 +91,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension dirpath = Pathname.new(File.dirname(path)) # TODO: This regex will change some paths in plan HTML (not in a tag) - is that OK? - body.gsub(/([=\'\"\(]\s*)([^\s\'\"\)]+(#{@exts_regex_text}))/) do |match| + body.gsub(/([=\'\"\(,]\s*)([^\s\'\"\)]+(#{@exts_regex_text}))/) do |match| opening_character = $1 asset_path = $2