fs: fix isSubPath for top-level directories (#105)

This commit is contained in:
perses 2016-08-01 16:56:56 +03:00 committed by Matt Joiner
parent 00f406753a
commit 39cf5a7fde
2 changed files with 4 additions and 0 deletions

View File

@ -158,6 +158,9 @@ var (
)
func isSubPath(parent, child string) bool {
if len(parent) == 0 {
return len(child) > 0
}
if !strings.HasPrefix(child, parent) {
return false
}

View File

@ -214,6 +214,7 @@ func TestIsSubPath(t *testing.T) {
}{
{"", "", false},
{"", "/", true},
{"", "a", true},
{"a/b", "a/bc", false},
{"a/b", "a/b", false},
{"a/b", "a/b/c", true},