From 7e816c04c06f6bed4151bdb29698a62b189033a0 Mon Sep 17 00:00:00 2001 From: Ben Hollis Date: Sun, 1 Apr 2012 18:08:59 -0700 Subject: [PATCH] Make the asset_url helper use the sitemap page's destination_path if it's available, which means extensions that rewrite asset paths using reroute get rewritten paths output from all path helpers for free. This was necessary to make asset_hash work with asset_host. --- .../lib/middleman-core/core_extensions/assets.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/middleman-core/lib/middleman-core/core_extensions/assets.rb b/middleman-core/lib/middleman-core/core_extensions/assets.rb index 8db7e1ba..92cc4859 100644 --- a/middleman-core/lib/middleman-core/core_extensions/assets.rb +++ b/middleman-core/lib/middleman-core/core_extensions/assets.rb @@ -24,7 +24,14 @@ module Middleman::CoreExtensions::Assets # @return [String] The fully qualified asset url def asset_url(path, prefix="") # Don't touch assets which already have a full path - path.include?("://") ? path : File.join(http_prefix, prefix, path) + if path.include?("//") + path + else # rewrite paths to use their destination path + path = File.join(prefix, path) + path = sitemap.page(path).destination_path if sitemap.exists?(path) + + File.join(http_prefix, path) + end end end -end \ No newline at end of file +end