diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-07-19 13:51:16 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-07-19 13:51:16 +0100 |
commit | e07897872dd260a7ff21719b7d9206e8d7034ada (patch) | |
tree | b4da80cf2a593c07f75d713fde718e082e8ba0b5 /lualib | |
parent | 8f0370ca239e47796fc42f1abc4efc16231b99f2 (diff) | |
download | rspamd-e07897872dd260a7ff21719b7d9206e8d7034ada.tar.gz rspamd-e07897872dd260a7ff21719b7d9206e8d7034ada.zip |
[Feature] Selectors: Add `list` generator
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/lua_selectors.lua | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lualib/lua_selectors.lua b/lualib/lua_selectors.lua index 9af5f8f92..2a4782e8b 100644 --- a/lualib/lua_selectors.lua +++ b/lualib/lua_selectors.lua @@ -38,6 +38,7 @@ local M = "selectors" local E = {} local extractors = { + -- Plain id function ['id'] = { ['get_value'] = function(_, args) if args[1] then @@ -50,6 +51,18 @@ local extractors = { For example, `id('Something')` returns a string 'Something']], ['args_schema'] = {ts.string:is_optional()} }, + -- Similar but for making lists + ['list'] = { + ['get_value'] = function(_, args) + if args[1] then + return fun.map(tostring, args), 'string_list' + end + + return {},'string_list' + end, + ['description'] = [[Return a list from function's arguments or an empty list, +For example, `list('foo', 'bar')` returns a list {'foo', 'bar'}]], + }, -- Get source IP address ['ip'] = { ['get_value'] = function(task) |