Permalink
Browse files

Fixed superfluous ampersand when queries are embedded in paths

  • Loading branch information...
1 parent 49086d1 commit 5db97a709c89e353b31877b8a74e086b0f835d97 Carl Youngblood committed Nov 11, 2013
Showing with 7 additions and 0 deletions.
  1. +1 −0 lib/httparty/request.rb
  2. +6 −0 spec/httparty/request_spec.rb
View
@@ -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
@@ -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

0 comments on commit 5db97a7

Please sign in to comment.