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:
parent
923c457501
commit
0df8f6e905
2 changed files with 4 additions and 4 deletions
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue