Skip to content

Commit

Permalink
fix remove path to ignore empty names
Browse files Browse the repository at this point in the history
  • Loading branch information
wagoodman committed May 22, 2018
1 parent 488ec1b commit ea66c0e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions filetree.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ func (tree *Tree) RemovePath(path string) error {
nodeNames := strings.Split(path, "/")
node := tree.Root()
for _, name := range nodeNames {
if node.children[name] != nil {
node = node.children[name]
} else {
if name == "" {
continue
}
if node.children[name] == nil {
return errors.New("Path does not exist")
}
node = node.children[name]
}
// this node's parent should be a leaf
return node.Remove()
Expand Down

0 comments on commit ea66c0e

Please sign in to comment.