diff options
author | thedarkone <thedarkone2@gmail.com> | 2010-09-22 20:18:05 +0200 |
---|---|---|
committer | thedarkone <thedarkone2@gmail.com> | 2010-09-27 17:45:58 +0200 |
commit | 05e53b4c1a3422131f73598848b0332cdc793f69 (patch) | |
tree | 2f34d9e2ec2cc9dced65bde220c716d9e316636a /actionpack/lib | |
parent | f2e0b3575e8c84cd23b75fcbfee83e7c683781ef (diff) | |
download | rails-05e53b4c1a3422131f73598848b0332cdc793f69.tar.gz rails-05e53b4c1a3422131f73598848b0332cdc793f69.tar.bz2 rails-05e53b4c1a3422131f73598848b0332cdc793f69.zip |
Optimize relative_url_root rewriting code.
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/helpers/asset_tag_helper.rb | 8 |
1 files changed, 5 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 687cb83d75..bf57321e86 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helper.rb @@ -718,6 +718,10 @@ module ActionView "#{host}#{source}" end + def rewrite_relative_url_root(source, relative_url_root) + relative_url_root && !source.starts_with?("#{relative_url_root}/") ? "#{relative_url_root}#{source}" : source + end + # Add the the extension +ext+ if not present. Return full URLs otherwise untouched. # Prefix with <tt>/dir/</tt> if lacking a leading +/+. Account for relative URL # roots. Rewrite the asset path for cache-busting asset ids. Include @@ -733,9 +737,7 @@ module ActionView source = rewrite_asset_path(source, config.asset_path) has_request = controller.respond_to?(:request) - if has_request && include_host && source !~ %r{^#{controller.config.relative_url_root}/} - source = "#{controller.config.relative_url_root}#{source}" - end + source = rewrite_relative_url_root(source, controller.config.relative_url_root) if has_request && include_host source = rewrite_host_and_protocol(source, has_request) if include_host source |