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

@ -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