1
0
Fork 0
mirror of https://github.com/rest-client/rest-client.git synced 2022-11-09 13:49:40 -05:00

Fixed handling of arrays

This commit is contained in:
David Backeus 2010-03-04 15:49:53 +01:00 committed by Julien Kirch
parent 923c457501
commit 0df8f6e905
2 changed files with 4 additions and 4 deletions

View file

@ -61,7 +61,7 @@ module RestClient
result += flatten_params(value, calculated_key)
elsif value.is_a? Array
value.each do |elem|
result << [calculated_key, elem]
result << ["#{calculated_key}[]", elem]
end
else
result << [calculated_key, value]

View file

@ -33,11 +33,11 @@ describe RestClient::Payload do
should == "foo[bar]=baz"
end
it "should properyl handle arrays as repeated parameters" do
it "should properly handle arrays as repeated parameters" do
RestClient::Payload::UrlEncoded.new({:foo => ['bar']}).to_s.
should == "foo=bar"
should == "foo[]=bar"
RestClient::Payload::UrlEncoded.new({:foo => ['bar', 'baz']}).to_s.
should == "foo=bar&foo=baz"
should == "foo[]=bar&foo[]=baz"
end
end