diff --git a/spec/http_spec.cr b/spec/http_spec.cr index 37e2604..d849207 100644 --- a/spec/http_spec.cr +++ b/spec/http_spec.cr @@ -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"} diff --git a/src/mechanize/http/agent.cr b/src/mechanize/http/agent.cr index 82bd588..5314fe7 100644 --- a/src/mechanize/http/agent.cr +++ b/src/mechanize/http/agent.cr @@ -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"