Fix asset_url with asset_hash (#1919)
* Fix asset_url with asset_hash. * Fix asset hashes.
This commit is contained in:
parent
5de9e86a55
commit
38a9025560
2 changed files with 10 additions and 1 deletions
|
@ -118,7 +118,9 @@ module Middleman
|
||||||
# relative path, since it only takes absolute url paths.
|
# relative path, since it only takes absolute url paths.
|
||||||
dest_path = url_for(app, path, options.merge(relative: false))
|
dest_path = url_for(app, path, options.merge(relative: false))
|
||||||
|
|
||||||
result = if resource = app.sitemap.find_resource_by_destination_path(dest_path)
|
result = if resource = app.sitemap.find_resource_by_path(dest_path)
|
||||||
|
resource.url
|
||||||
|
elsif resource = app.sitemap.find_resource_by_destination_path(dest_path)
|
||||||
resource.url
|
resource.url
|
||||||
else
|
else
|
||||||
path = ::File.join(prefix, path)
|
path = ::File.join(prefix, path)
|
||||||
|
|
|
@ -162,6 +162,13 @@ describe Middleman::Util do
|
||||||
expect( Middleman::Util.asset_url( @mm, '/how/about/that.html' ) ).to eq '/how/about/that/'
|
expect( Middleman::Util.asset_url( @mm, '/how/about/that.html' ) ).to eq '/how/about/that/'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "returns a resource url when asset_hash is on" do
|
||||||
|
Given.fixture 'asset-hash-app'
|
||||||
|
@mm = Middleman::Application.new
|
||||||
|
|
||||||
|
expect( Middleman::Util.asset_url( @mm, '100px.png', 'images') ).to match %r|/images/100px-[a-f0-9]+.png|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "::find_related_files" do
|
describe "::find_related_files" do
|
||||||
|
|
Loading…
Reference in a new issue