Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #7956 from josh/ignore-asset-url-query-or-anchor

Ignore asset url query string or anchor when generating path
  • Loading branch information...
commit 4f4417314c9f1e81bc7a11b569d85ace1f8384f8 2 parents dc126cf + c4276dd
@rafaelfranca rafaelfranca authored
View
4 actionpack/lib/action_view/helpers/asset_url_helper.rb
@@ -122,6 +122,8 @@ def asset_path(source, options = {})
return "" unless source.present?
return source if source =~ URI_REGEXP
+ tail, source = source[/([\?#].+)$/], source.sub(/([\?#].+)$/, '')
+
if extname = compute_asset_extname(source, options)
source = "#{source}#{extname}"
end
@@ -140,7 +142,7 @@ def asset_path(source, options = {})
source = "#{host}#{source}"
end
- source
+ "#{source}#{tail}"
end
alias_method :path_to_asset, :asset_path # aliased to avoid conflicts with a asset_path named route
View
19 actionpack/test/template/asset_tag_helper_test.rb
@@ -73,7 +73,12 @@ def url_for(*args)
%(javascript_path("super/xmlhr")) => %(/javascripts/super/xmlhr.js),
%(javascript_path("/super/xmlhr.js")) => %(/super/xmlhr.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 = {
@@ -285,6 +290,14 @@ def url_for(*args)
%(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
result = nil
assert_deprecated do
@@ -466,6 +479,10 @@ def test_audio_tag
AudioLinkToTag.each { |method, tag| assert_dom_equal(tag, eval(method)) }
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
options = {:autoplay => true}
video_tag('video', options)
Please sign in to comment.
Something went wrong with that request. Please try again.