fix unexpected behaviour when get uri with path and query parameter
parent
64bccad495
commit
2c73aa2bcf
|
@ -1,5 +1,6 @@
|
|||
require "./spec_helper"
|
||||
WebMock.stub(:get, "http://example.com/?foo=bar&foo1=bar2")
|
||||
WebMock.stub(:get, "http://example.com/path?foo=bar&foo1=bar2")
|
||||
WebMock.stub(:post, "http://example.com/post")
|
||||
.with(body: "email=foobar", headers: {"Content-Type" => "application/x-www-form-urlencoded"})
|
||||
.to_return(body: "success")
|
||||
|
@ -40,6 +41,14 @@ describe "Mechanize HTTP test" do
|
|||
page.uri.to_s.should eq uri
|
||||
end
|
||||
|
||||
it "GET with query parameter with path" do
|
||||
agent = Mechanize.new
|
||||
uri = "http://example.com/path?foo=bar&foo1=bar2"
|
||||
page = agent.get(uri)
|
||||
page.code.should eq 200
|
||||
page.uri.to_s.should eq uri
|
||||
end
|
||||
|
||||
it "simple POST" do
|
||||
agent = Mechanize.new
|
||||
query = {"email" => "foobar"}
|
||||
|
|
|
@ -84,6 +84,7 @@ class Mechanize
|
|||
body : String?) : ::HTTP::Client::Response?
|
||||
request_log(uri, method)
|
||||
path = uri.path
|
||||
path += "?#{uri.query.not_nil!}" if uri.query
|
||||
|
||||
case uri.scheme.not_nil!.downcase
|
||||
when "http", "https"
|
||||
|
|
Loading…
Reference in New Issue