From 0bef3b911cc262a007fb4412d864c1832d1268ad Mon Sep 17 00:00:00 2001 From: Gustav Eikaas <46537983+GustavEikaas@users.noreply.github.com> Date: Tue, 31 Dec 2024 16:40:05 +0100 Subject: fix(vim.fs): joinpath() does not normalize slashes on Windows #31782 --- test/functional/lua/fs_spec.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/functional/lua') diff --git a/test/functional/lua/fs_spec.lua b/test/functional/lua/fs_spec.lua index 63444f5ba1..3c306e6824 100644 --- a/test/functional/lua/fs_spec.lua +++ b/test/functional/lua/fs_spec.lua @@ -323,6 +323,20 @@ describe('vim.fs', function() eq('foo/bar/baz', vim.fs.joinpath('foo', 'bar', 'baz')) eq('foo/bar/baz', vim.fs.joinpath('foo', '/bar/', '/baz')) end) + it('rewrites backslashes on Windows', function() + if is_os('win') then + eq('foo/bar/baz/zub/', vim.fs.joinpath([[foo]], [[\\bar\\\\baz]], [[zub\]])) + else + eq([[foo/\\bar\\\\baz/zub\]], vim.fs.joinpath([[foo]], [[\\bar\\\\baz]], [[zub\]])) + end + end) + it('strips redundant slashes', function() + if is_os('win') then + eq('foo/bar/baz/zub/', vim.fs.joinpath([[foo//]], [[\\bar\\\\baz]], [[zub\]])) + else + eq('foo/bar/baz/zub/', vim.fs.joinpath([[foo]], [[//bar////baz]], [[zub/]])) + end + end) end) describe('normalize()', function() -- cgit