File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ def self.encode(value, prefix = nil)
58
58
# @parameter value [String] The unescaped key.
59
59
def self . scan ( string )
60
60
string . split ( '&' ) do |assignment |
61
+ next if assignment . empty?
62
+
61
63
key , value = assignment . split ( '=' , 2 )
62
64
63
65
yield unescape ( key ) , value . nil? ? value : unescape ( value )
Original file line number Diff line number Diff line change 76
76
Protocol ::HTTP ::URL . decode ( "=foo" )
77
77
end . to raise_exception ( ArgumentError , message : be =~ /Invalid key/ )
78
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
79
84
end
80
85
81
86
with '.unescape' do
You can’t perform that action at this time.
0 commit comments