提交 b6aa70c3 编写于 作者: P phoet

always use File.join

上级 0b6ac002
* 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
`image/x-icon`.
......
......@@ -134,11 +134,11 @@ def asset_path(source, options = {})
relative_url_root = defined?(config.relative_url_root) && config.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
if host = compute_asset_host(source, options)
source = "#{host}#{source}"
source = File.join(host, source)
end
"#{source}#{tail}"
......
......@@ -309,6 +309,14 @@ def test_asset_path_tag
AssetPathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
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
assert_equal "/robots.txt", compute_asset_path("robots.txt")
assert_equal "/robots.txt", compute_asset_path("/robots.txt")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册