Changeset 6162
- Timestamp:
- 02/18/07 07:23:57 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_view/helpers/asset_tag_helper.rb
r6161 r6162 11 11 # linking to them. 12 12 # 13 # ActionController::Base.asset_host = " http://assets.example.com"13 # ActionController::Base.asset_host = "assets.example.com" 14 14 # image_tag("rails.png") 15 15 # => <img src="http://assets.example.com/images/rails.png" alt="Rails" /> … … 213 213 # Prefix with /dir/ if lacking a leading /. Account for relative URL 214 214 # roots. Rewrite the asset path for cache-busting asset ids. Include 215 # a single or wildcarded asset host if configured. 215 # a single or wildcarded asset host, if configured, with the correct 216 # request protocol. 216 217 def compute_public_path(source, dir, ext) 217 218 source += ".#{ext}" if File.extname(source).blank? … … 222 223 source = "#{@controller.request.relative_url_root}#{source}" 223 224 rewrite_asset_path!(source) 224 "#{compute_asset_host(source)}#{source}" 225 226 host = compute_asset_host(source) 227 unless host.blank? or host =~ %r{^[-a-z]+://} 228 host = "#{@controller.request.protocol}#{host}" 229 end 230 231 "#{host}#{source}" 225 232 end 226 233 end trunk/actionpack/test/template/asset_tag_helper_test.rb
r6161 r6162 190 190 "/collaboration/hieraki" 191 191 end 192 193 def protocol 194 'gopher://' 195 end 192 196 end.new 193 197 … … 231 235 ActionController::Base.asset_host = nil 232 236 end 237 238 def test_asset_host_without_protocol_should_use_request_protocol 239 ActionController::Base.asset_host = 'a.example.com' 240 assert_equal 'gopher://a.example.com/collaboration/hieraki/images/xml.png', image_path('xml.png') 241 ensure 242 ActionController::Base.asset_host = nil 243 end 233 244 end