private Method

UrlRewriter.rewrite_url(options)

Given a path and options, returns a rewritten URL string

Source Code

# File action_controller/url_rewriter.rb, line 93
def rewrite_url(options)
  rewritten_url = ""

  unless options[:only_path]
    rewritten_url << (options[:protocol] || @request.protocol)
    rewritten_url << "://" unless rewritten_url.match("://")
    rewritten_url << rewrite_authentication(options)
    rewritten_url << (options[:host] || @request.host_with_port)
    rewritten_url << ":#{options.delete(:port)}" if options.key?(:port)
  end

  path = rewrite_path(options)
  rewritten_url << @request.relative_url_root.to_s unless options[:skip_relative_url_root]
  rewritten_url << (options[:trailing_slash] ? path.sub(/\?|\z/) { "/" + $& } : path)
  rewritten_url << "##{options[:anchor]}" if options[:anchor]

  rewritten_url
end
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.