Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #245 from Billiam/issue/unsorting-request-params

Sorting query parameters undesireable
  • Loading branch information...
commit 7c1a19e67db724455a2caf1c6b34d3b3a2d0743c 2 parents 6cf4fc7 + ac468e0
@jnunemaker authored
Showing with 4 additions and 4 deletions.
  1. +2 −2 lib/httparty/request.rb
  2. +2 −2 spec/httparty/request_spec.rb
View
4 lib/httparty/request.rb
@@ -15,7 +15,7 @@ class Request #:nodoc:
SupportedURISchemes = [URI::HTTP, URI::HTTPS, URI::Generic]
NON_RAILS_QUERY_STRING_NORMALIZER = Proc.new do |query|
- Array(query).map do |key, value|
+ Array(query).sort_by { |a| a[0].to_s }.map do |key, value|
if value.nil?
key.to_s
elsif value.is_a?(Array)
@@ -23,7 +23,7 @@ class Request #:nodoc:
else
HashConversions.to_params(key => value)
end
- end.flatten.sort.join('&')
+ end.flatten.join('&')
end
attr_accessor :http_method, :options, :last_response, :redirect, :last_uri
View
4 spec/httparty/request_spec.rb
@@ -21,8 +21,8 @@
end
it "URI encodes array values" do
- query_string = normalizer[{:people => ["Bob Marley", "Tim & Jon"]}]
- query_string.should == "people=Bob%20Marley&people=Tim%20%26%20Jon"
+ query_string = normalizer[{:people => ["Otis Redding", "Bob Marley", "Tim & Jon"], :page => 1, :xyzzy => 3}]
+ query_string.should == "page=1&people=Otis%20Redding&people=Bob%20Marley&people=Tim%20%26%20Jon&xyzzy=3"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.