diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-02-18 07:23:57 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-02-18 07:23:57 +0000 |
commit | c9260c556ca5e238225de23bf2fd2cf21400f8aa (patch) | |
tree | b2c02f8ee351b8b4dd12e52ec66cb68f9f58f154 /actionpack/lib/action_view | |
parent | 90c1207c384a39567777bc58f2de38eb7df236d7 (diff) | |
download | rails-c9260c556ca5e238225de23bf2fd2cf21400f8aa.tar.gz rails-c9260c556ca5e238225de23bf2fd2cf21400f8aa.tar.bz2 rails-c9260c556ca5e238225de23bf2fd2cf21400f8aa.zip |
Add request protocol to asset host if not given. Prefer setting asset host as hostname only, no request protocol.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6162 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_view')
-rw-r--r-- | actionpack/lib/action_view/helpers/asset_tag_helper.rb | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/actionpack/lib/action_view/helpers/asset_tag_helper.rb b/actionpack/lib/action_view/helpers/asset_tag_helper.rb index 8d62f07b8c..850615632f 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -10,7 +10,7 @@ module ActionView # in your environment.rb. These methods do not verify the assets exist before # linking to them. # - # ActionController::Base.asset_host = "http://assets.example.com" + # ActionController::Base.asset_host = "assets.example.com" # image_tag("rails.png") # => <img src="http://assets.example.com/images/rails.png" alt="Rails" /> # stylesheet_include_tag("application") @@ -212,7 +212,8 @@ module ActionView # Add the .ext if not present. Return full URLs otherwise untouched. # Prefix with /dir/ if lacking a leading /. Account for relative URL # roots. Rewrite the asset path for cache-busting asset ids. Include - # a single or wildcarded asset host if configured. + # a single or wildcarded asset host, if configured, with the correct + # request protocol. def compute_public_path(source, dir, ext) source += ".#{ext}" if File.extname(source).blank? if source =~ %r{^[-a-z]+://} @@ -221,7 +222,13 @@ module ActionView source = "/#{dir}/#{source}" unless source[0] == ?/ source = "#{@controller.request.relative_url_root}#{source}" rewrite_asset_path!(source) - "#{compute_asset_host(source)}#{source}" + + host = compute_asset_host(source) + unless host.blank? or host =~ %r{^[-a-z]+://} + host = "#{@controller.request.protocol}#{host}" + end + + "#{host}#{source}" end end |