aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/lua_util.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-03-24 15:21:33 +0000
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-03-24 15:21:33 +0000
commit3496dd364745a2b747ae775b6a3804d4524054e5 (patch)
tree2f756b7fa4608bf086cb8e2d77f569c4df9a8164 /lualib/lua_util.lua
parent3f5b2773a6afbe21f499b620f20416bcb4247a33 (diff)
downloadrspamd-3496dd364745a2b747ae775b6a3804d4524054e5.tar.gz
rspamd-3496dd364745a2b747ae775b6a3804d4524054e5.zip
[Minor] Add a utility to join path components
Diffstat (limited to 'lualib/lua_util.lua')
-rw-r--r--lualib/lua_util.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/lualib/lua_util.lua b/lualib/lua_util.lua
index ea193a975..e745099a7 100644
--- a/lualib/lua_util.lua
+++ b/lualib/lua_util.lua
@@ -1556,6 +1556,24 @@ end
exports.strip_lua_comments = strip_lua_comments
+---[[[
+-- @function lua_util.join_path(...)
+-- Joins path components into a single path string using the appropriate separator
+-- for the current operating system.
+--
+-- @param ... Any number of path components to join together.
+-- @return A single path string, with components separated by the appropriate separator.
+--
+---]]]
+local path_sep = package.config:sub(1,1) or '/'
+local function join_path(...)
+ local components = {...}
+
+ -- Join components using separator
+ return table.concat(components, path_sep)
+end
+exports.join_path = join_path
+
-- Defines symbols priorities for common usage in prefilters/postfilters
exports.symbols_priorities = {
top = 10, -- Symbols must be executed first (or last), such as settings