Skip to content

Commit

Permalink
fix: map repeated URL parameters with single value to a table
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavol Ostertag committed Oct 23, 2023
1 parent edc1458 commit d7f7fa8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kong/tools/protojson.lua
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,11 @@ json_to_message = function( m, m_type, path )
elseif ( f_label == "repeated" or f_label == "packed" ) then
pm[ f_name ] = {}

-- if the input is just a scalar - might happen for single-value table
if ( type( m[ name ] ) == "string" or type( m[ name ] ) == "number" ) then
m[ name ] = { m[ name ] } -- convert to a table
end

for k, v in ipairs( m[ name ] or {} ) do
table.insert( pm[ f_name ], json_to_field( v, f_type, ( "%s[%d]" ):format( p, k ) ) )
end
Expand Down

0 comments on commit d7f7fa8

Please sign in to comment.