diff options
author | Evgeni Chasnovski <evgeni.chasnovski@gmail.com> | 2023-06-18 14:49:33 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-18 06:49:33 -0500 |
commit | 8a7e3353eb5bffb10015254917361266b4b20511 (patch) | |
tree | 35055b4a66d92c9099eeb92bf7f84ff38774d2fe /runtime/lua/vim/fs.lua | |
parent | 7e301ed5b9f72a98086c7004d090ad9aef137485 (diff) | |
download | rneovim-8a7e3353eb5bffb10015254917361266b4b20511.tar.gz rneovim-8a7e3353eb5bffb10015254917361266b4b20511.tar.bz2 rneovim-8a7e3353eb5bffb10015254917361266b4b20511.zip |
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>
Diffstat (limited to 'runtime/lua/vim/fs.lua')
-rw-r--r-- | runtime/lua/vim/fs.lua | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/runtime/lua/vim/fs.lua b/runtime/lua/vim/fs.lua index c89147dbd2..cdb314fa3d 100644 --- a/runtime/lua/vim/fs.lua +++ b/runtime/lua/vim/fs.lua @@ -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 |