fix(fs.lua): normalize slash truncation (#23753)

Preserve last slash in windows' root drive directories
This commit is contained in:
Mike
2023-07-18 08:36:04 +02:00
committed by GitHub
parent 80cf0f3d29
commit e4da418ba8
2 changed files with 10 additions and 1 deletions

View File

@@ -348,7 +348,11 @@ function M.normalize(path, opts)
path = path:gsub('%$([%w_]+)', vim.uv.os_getenv)
end
return (path:gsub('\\', '/'):gsub('/+', '/'):gsub('(.)/$', '%1'))
path = path:gsub('\\', '/'):gsub('/+', '/')
if iswin and path:match('^%w:/$') then
return path
end
return (path:gsub('(.)/$', '%1'))
end
return M