mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #14932 from phoet/use_file_join
always use File.join in asset_path
This commit is contained in:
commit
492282d20d
3 changed files with 20 additions and 2 deletions
|
@ -1,3 +1,13 @@
|
||||||
|
* Change `asset_path` to use File.join to create proper paths (#14932):
|
||||||
|
|
||||||
|
https://some.host.com//assets/some.js
|
||||||
|
|
||||||
|
becomes
|
||||||
|
|
||||||
|
https://some.host.com/assets/some.js
|
||||||
|
|
||||||
|
*Peter Schröder*
|
||||||
|
|
||||||
* Change `favicon_link_tag` default mimetype from `image/vnd.microsoft.icon` to
|
* Change `favicon_link_tag` default mimetype from `image/vnd.microsoft.icon` to
|
||||||
`image/x-icon`.
|
`image/x-icon`.
|
||||||
|
|
||||||
|
|
|
@ -134,11 +134,11 @@ module ActionView
|
||||||
|
|
||||||
relative_url_root = defined?(config.relative_url_root) && config.relative_url_root
|
relative_url_root = defined?(config.relative_url_root) && config.relative_url_root
|
||||||
if relative_url_root
|
if relative_url_root
|
||||||
source = "#{relative_url_root}#{source}" unless source.starts_with?("#{relative_url_root}/")
|
source = File.join(relative_url_root, source) unless source.starts_with?("#{relative_url_root}/")
|
||||||
end
|
end
|
||||||
|
|
||||||
if host = compute_asset_host(source, options)
|
if host = compute_asset_host(source, options)
|
||||||
source = "#{host}#{source}"
|
source = File.join(host, source)
|
||||||
end
|
end
|
||||||
|
|
||||||
"#{source}#{tail}"
|
"#{source}#{tail}"
|
||||||
|
|
|
@ -309,6 +309,14 @@ class AssetTagHelperTest < ActionView::TestCase
|
||||||
AssetPathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
|
AssetPathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_asset_path_tag_to_not_create_duplicate_slashes
|
||||||
|
@controller.config.asset_host = "host/"
|
||||||
|
assert_dom_equal('http://host/foo', asset_path("foo"))
|
||||||
|
|
||||||
|
@controller.config.relative_url_root = '/some/root/'
|
||||||
|
assert_dom_equal('http://host/some/root/foo', asset_path("foo"))
|
||||||
|
end
|
||||||
|
|
||||||
def test_compute_asset_public_path
|
def test_compute_asset_public_path
|
||||||
assert_equal "/robots.txt", compute_asset_path("robots.txt")
|
assert_equal "/robots.txt", compute_asset_path("robots.txt")
|
||||||
assert_equal "/robots.txt", compute_asset_path("/robots.txt")
|
assert_equal "/robots.txt", compute_asset_path("/robots.txt")
|
||||||
|
|
Loading…
Reference in a new issue