Skip to content

Commit

Permalink
Fixed superfluous ampersand when queries are embedded in paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Youngblood committed Nov 11, 2013
1 parent 49086d1 commit 5db97a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/httparty/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def query_string(uri)
query_string_parts << options[:query] unless options[:query].nil?
end

query_string_parts.reject!(&:empty?) unless query_string_parts == [""]
query_string_parts.size > 0 ? query_string_parts.join('&') : nil
end

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 append an ampersand when queries are embedded in paths" do
@request.path = "/path?a=1"
@request.options[:query] = {}
@request.uri.query.should == "a=1"
end

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

0 comments on commit 5db97a7

Please sign in to comment.