mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ignore asset url query string or anchor when appending extensions and computing public path
This commit is contained in:
parent
046ab843b8
commit
c4276ddf38
2 changed files with 21 additions and 2 deletions
|
@ -122,6 +122,8 @@ module ActionView
|
||||||
return "" unless source.present?
|
return "" unless source.present?
|
||||||
return source if source =~ URI_REGEXP
|
return source if source =~ URI_REGEXP
|
||||||
|
|
||||||
|
tail, source = source[/([\?#].+)$/], source.sub(/([\?#].+)$/, '')
|
||||||
|
|
||||||
if extname = compute_asset_extname(source, options)
|
if extname = compute_asset_extname(source, options)
|
||||||
source = "#{source}#{extname}"
|
source = "#{source}#{extname}"
|
||||||
end
|
end
|
||||||
|
@ -140,7 +142,7 @@ module ActionView
|
||||||
source = "#{host}#{source}"
|
source = "#{host}#{source}"
|
||||||
end
|
end
|
||||||
|
|
||||||
source
|
"#{source}#{tail}"
|
||||||
end
|
end
|
||||||
alias_method :path_to_asset, :asset_path # aliased to avoid conflicts with a asset_path named route
|
alias_method :path_to_asset, :asset_path # aliased to avoid conflicts with a asset_path named route
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,12 @@ class AssetTagHelperTest < ActionView::TestCase
|
||||||
%(javascript_path("super/xmlhr")) => %(/javascripts/super/xmlhr.js),
|
%(javascript_path("super/xmlhr")) => %(/javascripts/super/xmlhr.js),
|
||||||
%(javascript_path("/super/xmlhr.js")) => %(/super/xmlhr.js),
|
%(javascript_path("/super/xmlhr.js")) => %(/super/xmlhr.js),
|
||||||
%(javascript_path("xmlhr.min")) => %(/javascripts/xmlhr.min.js),
|
%(javascript_path("xmlhr.min")) => %(/javascripts/xmlhr.min.js),
|
||||||
%(javascript_path("xmlhr.min.js")) => %(/javascripts/xmlhr.min.js)
|
%(javascript_path("xmlhr.min.js")) => %(/javascripts/xmlhr.min.js),
|
||||||
|
|
||||||
|
%(javascript_path("xmlhr.js?123")) => %(/javascripts/xmlhr.js?123),
|
||||||
|
%(javascript_path("xmlhr.js?body=1")) => %(/javascripts/xmlhr.js?body=1),
|
||||||
|
%(javascript_path("xmlhr.js#hash")) => %(/javascripts/xmlhr.js#hash),
|
||||||
|
%(javascript_path("xmlhr.js?123#hash")) => %(/javascripts/xmlhr.js?123#hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
PathToJavascriptToTag = {
|
PathToJavascriptToTag = {
|
||||||
|
@ -285,6 +290,14 @@ class AssetTagHelperTest < ActionView::TestCase
|
||||||
%(audio_tag(["audio.mp3", "audio.ogg"], :autobuffer => true, :controls => true)) => %(<audio autobuffer="autobuffer" controls="controls"><source src="/audios/audio.mp3" /><source src="/audios/audio.ogg" /></audio>)
|
%(audio_tag(["audio.mp3", "audio.ogg"], :autobuffer => true, :controls => true)) => %(<audio autobuffer="autobuffer" controls="controls"><source src="/audios/audio.mp3" /><source src="/audios/audio.ogg" /></audio>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FontPathToTag = {
|
||||||
|
%(font_path("font.eot")) => %(/fonts/font.eot),
|
||||||
|
%(font_path("font.eot#iefix")) => %(/fonts/font.eot#iefix),
|
||||||
|
%(font_path("font.woff")) => %(/fonts/font.woff),
|
||||||
|
%(font_path("font.ttf")) => %(/fonts/font.ttf),
|
||||||
|
%(font_path("font.ttf?123")) => %(/fonts/font.ttf?123)
|
||||||
|
}
|
||||||
|
|
||||||
def test_autodiscovery_link_tag_deprecated_types
|
def test_autodiscovery_link_tag_deprecated_types
|
||||||
result = nil
|
result = nil
|
||||||
assert_deprecated do
|
assert_deprecated do
|
||||||
|
@ -466,6 +479,10 @@ class AssetTagHelperTest < ActionView::TestCase
|
||||||
AudioLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
|
AudioLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_font_path
|
||||||
|
FontPathToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
|
||||||
|
end
|
||||||
|
|
||||||
def test_video_audio_tag_does_not_modify_options
|
def test_video_audio_tag_does_not_modify_options
|
||||||
options = {:autoplay => true}
|
options = {:autoplay => true}
|
||||||
video_tag('video', options)
|
video_tag('video', options)
|
||||||
|
|
Loading…
Reference in a new issue