fix remove path to ignore empty names
This commit is contained in:
parent
488ec1b047
commit
ea66c0e810
@ -57,11 +57,13 @@ func (tree *Tree) RemovePath(path string) error {
|
|||||||
nodeNames := strings.Split(path, "/")
|
nodeNames := strings.Split(path, "/")
|
||||||
node := tree.Root()
|
node := tree.Root()
|
||||||
for _, name := range nodeNames {
|
for _, name := range nodeNames {
|
||||||
if node.children[name] != nil {
|
if name == "" {
|
||||||
node = node.children[name]
|
continue
|
||||||
} else {
|
}
|
||||||
|
if node.children[name] == nil {
|
||||||
return errors.New("Path does not exist")
|
return errors.New("Path does not exist")
|
||||||
}
|
}
|
||||||
|
node = node.children[name]
|
||||||
}
|
}
|
||||||
// this node's parent should be a leaf
|
// this node's parent should be a leaf
|
||||||
return node.Remove()
|
return node.Remove()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user