diff --git a/middleman-core/features/asset_hash.feature b/middleman-core/features/asset_hash.feature index 0b61cb42..4e9b293d 100644 --- a/middleman-core/features/asset_hash.feature +++ b/middleman-core/features/asset_hash.feature @@ -179,16 +179,10 @@ Feature: Assets get file hashes appended to them and references to them are upda | javascripts/application-1d8d5276.js | | stylesheets/site-7474cadd.css | - # @wip Currently broken, we should move all asset-host functionality out of Compass and into something more similar to asset_hash with Rack-based rewrites - # Scenario: Enabling an asset host and referencing assets in CSS with URL fragments are rewritten correctly - # Given a successfully built app at "asset-hash-host-app" - # When I cd to "build" - - # Then the following files should exist: - # | images/100px-5fd6fb90.jpg | - # | stylesheets/fragment-c058ecb2.css | - # And the following files should not exist: - # | images/100px.jpg | - - # And the file "stylesheets/fragment-c058ecb2.css" should contain "http://middlemanapp.com/images/100px-5fd6fb90.jpg#test" - # And the file "stylesheets/fragment-c058ecb2.css" should not contain "http://middlemanapp.com/images/100px.jpg#test" + Scenario: Already minified files should still be hashed + Given a successfully built app at "asset-hash-minified-app" + When I cd to "build" + Then the following files should exist: + | javascripts/jquery.min-276c87ff.js | + And the following files should not exist: + | javascripts/jquery.min.js | diff --git a/middleman-core/fixtures/asset-hash-minified-app b/middleman-core/fixtures/asset-hash-minified-app new file mode 160000 index 00000000..a8bd04e5 --- /dev/null +++ b/middleman-core/fixtures/asset-hash-minified-app @@ -0,0 +1 @@ +Subproject commit a8bd04e58affa118f8af7f1c363ee96ad6086b48 diff --git a/middleman-core/lib/middleman-core/util.rb b/middleman-core/lib/middleman-core/util.rb index 226b6479..18e13435 100644 --- a/middleman-core/lib/middleman-core/util.rb +++ b/middleman-core/lib/middleman-core/util.rb @@ -336,10 +336,15 @@ module Middleman opening_character = $1 asset_path = $2 - uri = ::Addressable::URI.parse(asset_path) - if uri.relative? && uri.host.nil? && (result = yield(asset_path)) - "#{opening_character}#{result}" - else + begin + uri = ::Addressable::URI.parse(asset_path) + + if uri.relative? && uri.host.nil? && (result = yield(asset_path)) + "#{opening_character}#{result}" + else + match + end + rescue ::Addressable::URI::InvalidURIError match end end