We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cbb8ae2 commit fe31f2eCopy full SHA for fe31f2e
lib/protocol/http/url.rb
@@ -58,6 +58,8 @@ def self.encode(value, prefix = nil)
58
# @parameter value [String] The unescaped key.
59
def self.scan(string)
60
string.split('&') do |assignment|
61
+ next if assignment.empty?
62
+
63
key, value = assignment.split('=', 2)
64
65
yield unescape(key), value.nil? ? value : unescape(value)
test/protocol/http/url.rb
@@ -76,6 +76,11 @@
76
Protocol::HTTP::URL.decode("=foo")
77
end.to raise_exception(ArgumentError, message: be =~ /Invalid key/)
78
end
79
80
+ it "fails with empty pairs" do
81
+ expect(Protocol::HTTP::URL.decode("a=1&&b=2")).to be == {"a" => "1", "b" => "2"}
82
+ expect(Protocol::HTTP::URL.decode("a&&b")).to be == {"a" => nil, "b" => nil}
83
+ end
84
85
86
with '.unescape' do
0 commit comments