Permalink
Browse files

Merge pull request #252 from cayblood/master

Fixed superfluous ampersand when queries are embedded in paths
  • Loading branch information...
2 parents 49086d1 + 5db97a7 commit be7166c061434417a25814920766dfb36aed2977 @jnunemaker 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
@@ -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 be7166c

Please sign in to comment.