Method: OEHClient::Helper::Request.format_url
- Defined in:
- lib/oehclient/helper.rb
.format_url(url, params) ⇒ Object
request_url builds the target request URL with the passed parameters, URL encoding the parameters
as necessary to create a valid request
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/oehclient/helper.rb', line 21 def self.format_url(url, params) # for each of the parameters, build a single query parameter string parameter_part = "" params.each do |key, value| # if there is more than one argument, add the apppropriate separator (&) between # query parameters parameter_part << "&" if (parameter_part.length > 0) # URL Encode the value of the property parameter_part << "#{key.to_s}=#{ERB::Util.url_encode(value)}" end # return the fully-qualified URL with parameters (if passsed) (parameter_part.length > 0 ? "#{url}?#{parameter_part}" : "#{url}") end |