mirror of
https://github.com/neovim/neovim.git
synced 2026-04-30 19:24:09 +00:00
fix(fs): make normalize() work with '/' path (#24047)
Problem: Current implementation of "remove trailing /" doesn't account for the case of literal '/' as path. Solution: Remove trailing / only if it preceded by something else. Co-authored by: notomo <notomo.motono@gmail.com>
This commit is contained in:
committed by
GitHub
parent
7e301ed5b9
commit
8a7e3353eb
@@ -348,9 +348,7 @@ function M.normalize(path, opts)
|
||||
path = path:gsub('%$([%w_]+)', vim.uv.os_getenv)
|
||||
end
|
||||
|
||||
path = path:gsub('\\', '/'):gsub('/+', '/')
|
||||
|
||||
return path:sub(-1) == '/' and path:sub(1, -2) or path
|
||||
return (path:gsub('\\', '/'):gsub('/+', '/'):gsub('(.)/$', '%1'))
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
Reference in New Issue
Block a user