diff --git a/lua/plenary/path.lua b/lua/plenary/path.lua index 0865f2e3..fd8214c8 100644 --- a/lua/plenary/path.lua +++ b/lua/plenary/path.lua @@ -265,7 +265,7 @@ function Path:new(...) end local obj = { - filename = path_string, + filename = path_string:gsub("/", sep):gsub("\\", sep), _sep = sep, } diff --git a/tests/plenary/path_spec.lua b/tests/plenary/path_spec.lua index 0f02db04..853082a5 100644 --- a/tests/plenary/path_spec.lua +++ b/tests/plenary/path_spec.lua @@ -44,6 +44,10 @@ describe("Path", function() assert.are.same(Path:new("lua", "plenary"), Path:new("lua", Path:new "plenary")) end) + it("can join paths with different separators", function() + assert.are.same(Path:new("path\\to"):joinpath("lua/plenary"), Path:new("path/to/lua/plenary")) + end) + it("inserts slashes", function() assert.are.same("lua" .. path.sep .. "plenary", Path:new("lua", "plenary").filename) end)