mirror of
https://github.com/wagoodman/dive
synced 2026-03-16 23:35:50 +01:00
fix remove path to ignore empty names
This commit is contained in:
parent
488ec1b047
commit
ea66c0e810
1 changed files with 5 additions and 3 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue