Skip to content
Permalink
Browse files

Add getGroupByPath

  • Loading branch information...
Raggaer committed Mar 30, 2019
1 parent 75b2f32 commit e44c5d30cd2cc8d8a976d50f501aad2dd5710f48
Showing with 38 additions and 0 deletions.
  1. +38 −0 group.go
@@ -118,6 +118,44 @@ func createNewGroup(f *form, input string) {
}
}

func getGroupByPath(path string) *gokeepasslib.Group {
// Try to retrieve entry by path
movedPaths := 0
paths := strings.Split(path, "/")
pathRange:
for i, path := range paths {
// If its the entry from the path
if i == len(paths)-1 {
e := currentGroup()
// Remove moved paths
groupHistory = groupHistory[0 : len(groupHistory)-movedPaths]
return e
}

// Move to next group
gid, err := strconv.Atoi(path)
if err != nil {
for x, g := range currentGroup().Groups {
if strings.ToLower(g.Name) == strings.ToLower(path) {
groupHistory = append(groupHistory, x)
continue pathRange
}
}
} else {
gid--
for x := range currentGroup().Groups {
if x == gid {
groupHistory = append(groupHistory, x)
movedPaths++
continue pathRange
}
}
}
}

return nil
}

func currentGroup() *gokeepasslib.Group {
g := &database.Content.Root.Groups[0]
for _, h := range groupHistory {

0 comments on commit e44c5d3

Please sign in to comment.
You can’t perform that action at this time.