Skip to content

Commit 5aa29e8

Browse files
fredwangwangjulienschmidt
authored andcommitted
path: fix missing root in paths with length 2 (#239)
1 parent d189839 commit 5aa29e8

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

path.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func CleanPath(p string) string {
4141
buf[0] = '/'
4242
}
4343

44-
trailing := n > 2 && p[n-1] == '/'
44+
trailing := n > 1 && p[n-1] == '/'
4545

4646
// A bit more clunky without a 'lazybuf' like the path package, but the loop
4747
// gets completely inlined (bufApp). So in contrast to the path package this

path_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ var cleanTests = []struct {
2222

2323
// missing root
2424
{"", "/"},
25+
{"a/", "/a/"},
2526
{"abc", "/abc"},
2627
{"abc/def", "/abc/def"},
2728
{"a/b/c", "/a/b/c"},

0 commit comments

Comments
 (0)