lib/curl.rb in curb-0.9.4 vs lib/curl.rb in curb-0.9.5
- old
+ new
@@ -46,10 +46,16 @@
http :OPTIONS, urlalize(url, params), nil, nil, &block
end
def self.urlalize(url, params={})
uri = URI(url)
- uri.query = params.map {|k,v| "#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}" }.join("&")
+ params_query = params.map {|k,v| "#{URI.escape(k.to_s)}=#{URI.escape(v.to_s)}" }.join("&")
+ # both uri.query and params_query not blank
+ if !(uri.query.nil? || uri.query.empty?) && !params_query.empty?
+ uri.query = "#{uri.query}&#{params_query}"
+ else
+ uri.query = "#{uri.query}#{params_query}"
+ end
uri.to_s
end
def self.postalize(params={})
params.respond_to?(:map) ? URI.encode_www_form(params) : (params.respond_to?(:to_s) ? params.to_s : params)