From 3ec55e1bcb675fb2affcd4977e9517054c9a5342 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sat, 12 Nov 2022 15:17:45 +0000 Subject: [PATCH] [Project] Add query encoding usage --- lualib/lua_maps.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua index b2f8dda92..88f0b894a 100644 --- a/lualib/lua_maps.lua +++ b/lualib/lua_maps.lua @@ -141,7 +141,13 @@ local function query_external_map(map_config, upstreams, key, callback, task) else -- query/header and no encode if map_config.method == 'query' then - -- TODO: encode key/value pairs into query params + local params_table = {} + for k,v in pairs(key) do + if type(v) == 'string' then + table.insert(params_table, string.format('%s=%s', url_encode_string(k), url_encode_string(v))) + end + end + url = string.format('%s?%s', url, table.concat(params_table, '&')) elseif map_config.method == 'header' then http_headers = key else @@ -150,7 +156,6 @@ local function query_external_map(map_config, upstreams, key, callback, task) "requested external map key with a wrong combination of encode and input; caller: %s:%s", caller.short_src, caller.currentline) callback(false, 'invalid map usage', 500, task) - return end end -- 2.39.5