Skip to content

Commit fded248

Browse files
committed
fix(path): fix bug in Path:copy()
1 parent 25b0cc8 commit fded248

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

lua/plenary/path.lua

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,14 @@ function Path:copy(opts)
592592
local dest = opts.destination
593593
-- handles `.`, `..`, `./`, and `../`
594594
if not Path.is_path(dest) then
595-
if type(dest) == "string" and dest:match "^%.%.?/?\\?.+" then
596-
dest = {
597-
uv.fs_realpath(dest:sub(1, 3)),
598-
dest:sub(4, #dest),
599-
}
595+
if type(dest) == "string" then
596+
local m = dest:match "^%.%.?/?\\?.+"
597+
if m then
598+
dest = {
599+
uv.fs_realpath(dest:sub(1, #m)),
600+
dest:sub(#m + 1),
601+
}
602+
end
600603
end
601604
dest = Path:new(dest)
602605
end

0 commit comments

Comments
 (0)