lib/rufus/verbs/endpoint.rb in rufus-verbs-0.5 vs lib/rufus/verbs/endpoint.rb in rufus-verbs-0.6

- old
+ new

@@ -241,11 +241,11 @@ [ opts[:scheme] || 'http', opts[:host], opts[:port] || 80, opts[:path] || '/', - opts[:query] || {} ] + opts[:query] || opts[:params] || {} ] elsif u u = URI.parse u.to_s unless u.is_a?(URI) [ u.scheme, @@ -260,11 +260,11 @@ opts[:scheme] = r[0] || @opts[:scheme] opts[:host] = r[1] || @opts[:host] opts[:port] = r[2] || @opts[:port] opts[:path] = r[3] || @opts[:path] - opts[:query] = r[4] || @opts[:query] + opts[:query] = r[4] || @opts[:query] || @opts[:params] opts.delete :path if opts[:path] == "" opts[:c_uri] = [ opts[:scheme], @@ -433,11 +433,11 @@ query = opts[:query] return path if not query or query.size < 1 - path + '?' + h_to_query(query) + path + '?' + h_to_query(query, opts) end # # "a=A&b=B" -> { "a" => "A", "b" => "B" } # @@ -453,12 +453,18 @@ end # # { "a" => "A", "b" => "B" } -> "a=A&b=B" # - def h_to_query (h) + def h_to_query (h, opts) - h.entries.collect { |e| e.join("=") }.join("&") + h.entries.collect { |k, v| + unless o(opts, :no_escape) + k = URI.escape k.to_s + v = URI.escape v.to_s + end + "#{k}=#{v}" + }.join("&") end # # Fills the request body (with the content of :d or :fd). #