fix(fs): duplicate path separator #21509

Fixes #21497
This commit is contained in:
Eric Haynes 2023-01-03 12:24:14 -05:00 committed by GitHub
parent 5e9508c702
commit 1b3c255f60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -74,7 +74,7 @@ end
---@private ---@private
local function join_paths(...) local function join_paths(...)
return table.concat({ ... }, '/') return (table.concat({ ... }, '/'):gsub('//+', '/'))
end end
--- Return an iterator over the files and directories located in {path} --- Return an iterator over the files and directories located in {path}

View File

@ -230,6 +230,11 @@ describe('vim.fs', function()
local dir, nvim = ... local dir, nvim = ...
return vim.fs.find(nvim, { path = dir, type = 'file' }) return vim.fs.find(nvim, { path = dir, type = 'file' })
]], test_build_dir, nvim_prog_basename)) ]], test_build_dir, nvim_prog_basename))
eq({nvim_dir}, exec_lua([[
local dir = ...
local parent, name = dir:match('^(.*/)([^/]+)$')
return vim.fs.find(name, { path = parent, upward = true, type = 'directory' })
]], nvim_dir))
end) end)
it('accepts predicate as names', function() it('accepts predicate as names', function()