diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-11-13 16:52:43 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2020-11-13 16:52:43 +0000 |
commit | b2c3f581ec2ca673959ce0c7ff374ff47ac73405 (patch) | |
tree | e5b39f45be9fa1f3dde18fbb72c37bfca551e0fe /lualib | |
parent | df5db936734ef1100bf31f0cb4fa0d2d1b4c70ed (diff) | |
download | rspamd-b2c3f581ec2ca673959ce0c7ff374ff47ac73405.tar.gz rspamd-b2c3f581ec2ca673959ce0c7ff374ff47ac73405.zip |
[Minor] Selectors: filter_string_nils utility transformation
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/lua_selectors/transforms.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lualib/lua_selectors/transforms.lua b/lualib/lua_selectors/transforms.lua index 1a27b775d..232a49b79 100644 --- a/lualib/lua_selectors/transforms.lua +++ b/lualib/lua_selectors/transforms.lua @@ -458,6 +458,17 @@ Empty string comes the first argument or 'true', non-empty string comes nil]], ['description'] = 'Converts a list of strings to numbers & returns a packed string', ['args_schema'] = {ts.string:is_optional()} }, + -- Filter nils from a list + ['filter_string_nils'] = { + ['types'] = { + ['string_list'] = true + }, + ['process'] = function(inp, _, _) + return fun.filter(function(val) return type(val) == 'string' and val ~= 'nil' end, inp), 'string_list' + end, + ['description'] = 'Removes all nils from a list of strings (when converted implicitly)', + ['args_schema'] = {} + }, } transform_function.match = transform_function.regexp |