Skip to content

Commit ee16319

Browse files
guerinonigopherbot
authored andcommitted
path/filepath: return cleaned path from Rel
As the doc says, Rel should return a cleaned path. Fixes golang#75763 Change-Id: Ic0f5a3b1da3cc4cf3c31fdb1a88ebcc4ea6f9169 Reviewed-on: https://go-review.googlesource.com/c/go/+/709675 Reviewed-by: Michael Pratt <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Sean Liao <[email protected]> Auto-Submit: Sean Liao <[email protected]> Reviewed-by: Carlos Amedee <[email protected]>
1 parent de9da0d commit ee16319

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/path/filepath/path.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ func Rel(basepath, targpath string) (string, error) {
248248
buf[n] = Separator
249249
copy(buf[n+1:], targ[t0:])
250250
}
251-
return string(buf), nil
251+
return Clean(string(buf)), nil
252252
}
253253
return targ[t0:], nil
254254
}

src/path/filepath/path_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,7 @@ var reltests = []RelTests{
15061506
{"/../../a/b", "/../../a/b/c/d", "c/d"},
15071507
{".", "a/b", "a/b"},
15081508
{".", "..", ".."},
1509+
{"", "../../.", "../.."},
15091510

15101511
// can't do purely lexically
15111512
{"..", ".", "err"},

0 commit comments

Comments
 (0)