Permalink
Browse files

use String#start_with? rather than creating regexps or comparing char…

…acter values
  • Loading branch information...
1 parent 0195846 commit b550eccc699f1df5796fa30cccf035a5135e905b @tenderlove tenderlove committed Aug 31, 2011
Showing with 2 additions and 2 deletions.
  1. +2 −2 actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -742,11 +742,11 @@ def compute_public_path(source, dir, ext = nil, include_host = true)
return source if is_uri?(source)
source += ".#{ext}" if rewrite_extension?(source, dir, ext)
- source = "/#{dir}/#{source}" unless source[0] == ?/
+ source = "/#{dir}/#{source}" unless source.start_with? '/'
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}/}
+ if has_request && include_host && !source.start_with?(controller.config.relative_url_root)
source = "#{controller.config.relative_url_root}#{source}"
end
source = rewrite_host_and_protocol(source, has_request) if include_host

0 comments on commit b550ecc

Please sign in to comment.