Merge pull request #24 from Kanezoh/fix-query-parameter-with-path

fix unexpected behaviour when get uri with path and query parameter
master
Kanezoh 2022-01-10 18:56:25 +09:00 committed by GitHub
commit f44ed2eea6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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"