Use the resource instead of the request path for auto asset helpers. Fixes #1326
This commit is contained in:
parent
2426abe6f5
commit
15d6210df8
5 changed files with 9 additions and 1 deletions
|
@ -6,6 +6,11 @@ Feature: Built-in auto_javascript_include_tag view helper
|
||||||
When I go to "/auto-js.html"
|
When I go to "/auto-js.html"
|
||||||
Then I should see "javascripts/auto-js.js"
|
Then I should see "javascripts/auto-js.js"
|
||||||
|
|
||||||
|
Scenario: Viewing the root path (directory index)
|
||||||
|
Given the Server is running at "auto-js-directory-index-app"
|
||||||
|
When I go to "/auto-js/index.html"
|
||||||
|
Then I should see "javascripts/auto-js.js"
|
||||||
|
|
||||||
Scenario: Viewing the root path (build mode)
|
Scenario: Viewing the root path (build mode)
|
||||||
Given a successfully built app at "auto-js-app"
|
Given a successfully built app at "auto-js-app"
|
||||||
When I cd to "build"
|
When I cd to "build"
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
activate :directory_indexes
|
|
@ -0,0 +1 @@
|
||||||
|
<%= auto_javascript_include_tag %>
|
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -118,7 +118,7 @@ class Middleman::CoreExtensions::DefaultHelpers < ::Middleman::Extension
|
||||||
|
|
||||||
# If the basename of the request as no extension, assume we are serving a
|
# If the basename of the request as no extension, assume we are serving a
|
||||||
# directory and join index_file to the path.
|
# directory and join index_file to the path.
|
||||||
path = File.join(asset_dir, current_path)
|
path = File.join(asset_dir, current_resource.path)
|
||||||
path = path.sub(/#{Regexp.escape(File.extname(path))}$/, ".#{asset_ext}")
|
path = path.sub(/#{Regexp.escape(File.extname(path))}$/, ".#{asset_ext}")
|
||||||
|
|
||||||
yield path if sitemap.find_resource_by_path(path)
|
yield path if sitemap.find_resource_by_path(path)
|
||||||
|
|
Loading…
Reference in a new issue