fix(fs.lua): normalize slash truncation

Preserve last slash in windows' root drive directories

(cherry picked from commit 886996ff74)
This commit is contained in:
Mike
2023-05-25 16:05:11 +02:00
committed by github-actions[bot]
parent b0abe426d6
commit c0c6294123
2 changed files with 10 additions and 1 deletions

View File

@@ -344,7 +344,11 @@ function M.normalize(path, opts)
path = path:gsub('%$([%w_]+)', vim.loop.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