Skip to content

Commit

Permalink
fix(fs): join_paths on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
gorillamoe committed Oct 13, 2024
1 parent a87cc34 commit 46cb0c5
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions lua/kulala/utils/fs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,13 @@ M.ps = M.get_path_separator()
---@return string
M.join_paths = function(...)
if M.get_os() == "windows" then
for i, v in ipairs({ ... }) do
for _, v in ipairs({ ... }) do
-- if the path contains at least one forward slash,
-- then it needs to be converted to backslashes
if v:match("/") then
local parts = {}
for j, p in ipairs({ ... }) do
if j == i then
table.insert(parts, p:sub(2):gsub("/", "\\"))
else
table.insert(parts, p:gsub("/", "\\"))
end
for _, p in ipairs({ ... }) do
table.insert(parts, p:gsub("/", "\\"))
end
return table.concat(parts, M.ps)
end
Expand Down

0 comments on commit 46cb0c5

Please sign in to comment.