fix unexpected behaviour when get uri with path and query parameter

master
Kanezoh 2022-01-10 10:44:27 +09:00
parent 64bccad495
commit 2c73aa2bcf
2 changed files with 10 additions and 0 deletions

View File

@ -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"}

View File

@ -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"