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)
5858 # @parameter value [String] The unescaped key.
5959 def self . scan ( string )
6060 string . split ( '&' ) do |assignment |
61+ next if assignment . empty?
62+
6163 key , value = assignment . split ( '=' , 2 )
6264
6365 yield unescape ( key ) , value . nil? ? value : unescape ( value )
Original file line number Diff line number Diff line change 7676 Protocol ::HTTP ::URL . decode ( "=foo" )
7777 end . to raise_exception ( ArgumentError , message : be =~ /Invalid key/ )
7878 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
7984 end
8085
8186 with '.unescape' do
You can’t perform that action at this time.
0 commit comments