Fix IsAncestor and IsDescendant under subsection

This commit is contained in:
Takayama Fumihiko
2020-04-23 23:59:17 +09:00
committed by Bjørn Erik Pedersen
parent ade27699e5
commit 27a4c4410c
2 changed files with 8 additions and 8 deletions

View File

@@ -54,8 +54,8 @@ func (pt pageTree) IsAncestor(other interface{}) (bool, error) {
return false, nil
}
if ref2.isSection() {
return strings.HasPrefix(ref2.key, ref1.key+"/"), nil
if strings.HasPrefix(ref2.key, ref1.key+"/") {
return true, nil
}
return strings.HasPrefix(ref2.key, ref1.key+cmBranchSeparator), nil
@@ -101,8 +101,8 @@ func (pt pageTree) IsDescendant(other interface{}) (bool, error) {
return false, nil
}
if ref1.isSection() {
return strings.HasPrefix(ref1.key, ref2.key+"/"), nil
if strings.HasPrefix(ref1.key, ref2.key+"/") {
return true, nil
}
return strings.HasPrefix(ref1.key, ref2.key+cmBranchSeparator), nil