Fix IsAncestor and IsDescendant when the same page is passed

This commit is contained in:
Takayama Fumihiko
2020-04-24 01:23:32 +09:00
committed by Bjørn Erik Pedersen
parent 5c41f41ad4
commit 8d5766d417
2 changed files with 12 additions and 4 deletions

View File

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