]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Minor] Add a utility to join path components
authorVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 24 Mar 2023 15:21:33 +0000 (15:21 +0000)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Fri, 24 Mar 2023 15:21:33 +0000 (15:21 +0000)
lualib/lua_util.lua

index ea193a97576ab2a6a49bb853891c90723652a632..e745099a70f12529cf034d7261d81e41a187d431 100644 (file)
@@ -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