Skip to content
This repository
Browse code

Merge pull request #10969 from davidcelis/case-insensitive-asset-path

Use a case insensitive URI Regexp for #asset_path
  • Loading branch information...
commit 0117f28b980e5f2d68ff9ff5862f3fdb0216e2a0 2 parents 0f89689 + 8fc3427
Rafael Mendonça França authored
2  actionpack/lib/action_view/helpers/asset_url_helper.rb
@@ -105,7 +105,7 @@ module Helpers
105 105
     #   )
106 106
     #
107 107
     module AssetUrlHelper
108  
-      URI_REGEXP = %r{^[-a-z]+://|^(?:cid|data):|^//}
  108
+      URI_REGEXP = %r{^[-a-z]+://|^(?:cid|data):|^//}i
109 109
 
110 110
       # Computes the path to asset in public directory. If :type
111 111
       # options is set, a file extension will be appended and scoped
7  actionpack/test/template/asset_tag_helper_test.rb
@@ -48,6 +48,9 @@ def url_for(*args)
48 48
     %(asset_path("style.min"))        => %(/style.min),
49 49
     %(asset_path("style.min.css"))    => %(/style.min.css),
50 50
 
  51
+    %(asset_path("http://www.outside.com/image.jpg")) => %(http://www.outside.com/image.jpg),
  52
+    %(asset_path("HTTP://www.outside.com/image.jpg")) => %(HTTP://www.outside.com/image.jpg),
  53
+
51 54
     %(asset_path("style", type: :stylesheet)) => %(/stylesheets/style.css),
52 55
     %(asset_path("xmlhr", type: :javascript)) => %(/javascripts/xmlhr.js),
53 56
     %(asset_path("xml.png", type: :image))    => %(/images/xml.png)
@@ -445,8 +448,8 @@ def test_image_alt
445 448
     [nil, '/', '/foo/bar/', 'foo/bar/'].each do |prefix|
446 449
       assert_equal 'Rails', image_alt("#{prefix}rails.png")
447 450
       assert_equal 'Rails', image_alt("#{prefix}rails-9c0a079bdd7701d7e729bd956823d153.png")
448  
-      assert_equal 'Long file name with hyphens', image_alt("#{prefix}long-file-name-with-hyphens.png") 
449  
-      assert_equal 'Long file name with underscores', image_alt("#{prefix}long_file_name_with_underscores.png")  
  451
+      assert_equal 'Long file name with hyphens', image_alt("#{prefix}long-file-name-with-hyphens.png")
  452
+      assert_equal 'Long file name with underscores', image_alt("#{prefix}long_file_name_with_underscores.png")
450 453
     end
451 454
   end
452 455
 

0 notes on commit 0117f28

Please sign in to comment.
Something went wrong with that request. Please try again.