Skip to content

Commit

Permalink
Merge pull request #189 from sullman/fix-duplicate-query-string-params
Browse files Browse the repository at this point in the history
Don't duplicate query string arguments.
  • Loading branch information
greatuserongithub committed Feb 2, 2013
2 parents 783f878 + e5bb508 commit d5c1859
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/httparty/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def request_uri(uri)
end

def uri
new_uri = path.relative? ? URI.parse("#{base_uri}#{path}") : path
new_uri = path.relative? ? URI.parse("#{base_uri}#{path}") : path.clone

# avoid double query string on redirects [#12]
unless redirect
Expand Down
6 changes: 6 additions & 0 deletions spec/httparty/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@
URI.unescape(@request.uri.query).should == ""
end

it "does not duplicate query string parameters when uri is called twice" do
@request.options[:query] = {:foo => :bar}
@request.uri
@request.uri.query.should == "foo=bar"
end

context "when representing an array" do
it "returns a Rails style query string" do
@request.options[:query] = {:foo => %w(bar baz)}
Expand Down

0 comments on commit d5c1859

Please sign in to comment.