fix #13579 joinPath("/foo/", "../a") is now /a (#13586)

This commit is contained in:
Andreas Rumpf 2020-03-05 15:31:22 +01:00 • committed by GitHub
commit 62c113ebc7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 0 deletions

View file

@ -76,6 +76,11 @@ proc addNormalizePath*(x: string; result: var string; state: var int;
if (state shr 1) >= 1:
var d = result.len
# f/..
# We could handle stripping trailing sep here: foo// => foo like this:
# while (d-1) > (state and 1) and result[d-1] in {DirSep, AltSep}: dec d
# but right now we instead handle it inside os.joinPath
# strip path component: foo/bar => foo
while (d-1) > (state and 1) and result[d-1] notin {DirSep, AltSep}:
dec d
if d > 0: