Handle invalid URLs in rewriter. Fixed #1638

This commit is contained in:
Thomas Reynolds 2015-12-13 12:32:21 -08:00
parent 658b28c337
commit d3a5494062
3 changed files with 17 additions and 17 deletions

View file

@ -179,16 +179,10 @@ Feature: Assets get file hashes appended to them and references to them are upda
| javascripts/application-1d8d5276.js | | javascripts/application-1d8d5276.js |
| stylesheets/site-7474cadd.css | | 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: Already minified files should still be hashed
# Scenario: Enabling an asset host and referencing assets in CSS with URL fragments are rewritten correctly Given a successfully built app at "asset-hash-minified-app"
# Given a successfully built app at "asset-hash-host-app" When I cd to "build"
# When I cd to "build" Then the following files should exist:
| javascripts/jquery.min-276c87ff.js |
# Then the following files should exist: And the following files should not exist:
# | images/100px-5fd6fb90.jpg | | javascripts/jquery.min.js |
# | 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"

@ -0,0 +1 @@
Subproject commit a8bd04e58affa118f8af7f1c363ee96ad6086b48

View file

@ -336,10 +336,15 @@ module Middleman
opening_character = $1 opening_character = $1
asset_path = $2 asset_path = $2
uri = ::Addressable::URI.parse(asset_path) begin
if uri.relative? && uri.host.nil? && (result = yield(asset_path)) uri = ::Addressable::URI.parse(asset_path)
"#{opening_character}#{result}"
else if uri.relative? && uri.host.nil? && (result = yield(asset_path))
"#{opening_character}#{result}"
else
match
end
rescue ::Addressable::URI::InvalidURIError
match match
end end
end end