From: perses Date: Mon, 1 Aug 2016 13:56:56 +0000 (+0300) Subject: fs: fix isSubPath for top-level directories (#105) X-Git-Tag: v1.0.0~618 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=39cf5a7fde8fea752436ed21d038714ad9657da6;p=btrtrc.git fs: fix isSubPath for top-level directories (#105) --- diff --git a/fs/torrentfs.go b/fs/torrentfs.go index 0f1cc9e6..55834a24 100644 --- a/fs/torrentfs.go +++ b/fs/torrentfs.go @@ -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 } diff --git a/fs/torrentfs_test.go b/fs/torrentfs_test.go index da83a75b..f3564124 100644 --- a/fs/torrentfs_test.go +++ b/fs/torrentfs_test.go @@ -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},