Add browser search and richer URL matching
This commit is contained in:
@@ -5,10 +5,13 @@ import "git.julianfamily.org/keepassgo/internal/vault"
|
||||
// HiddenRoot returns the single synthetic top-level vault group that should be
|
||||
// treated as an internal storage root rather than as a user-visible group.
|
||||
func HiddenRoot(model vault.Model) string {
|
||||
if !hasGroup(model.Groups, []string{KeepassRoot}) {
|
||||
return ""
|
||||
if hasGroup(model.Groups, []string{KeepassRoot}) {
|
||||
return KeepassRoot
|
||||
}
|
||||
return KeepassRoot
|
||||
if usesTopLevelRoot(model, KeepassRoot) {
|
||||
return KeepassRoot
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func hasGroup(groups [][]string, path []string) bool {
|
||||
|
||||
@@ -24,3 +24,20 @@ func TestHiddenRootIgnoresRecycleBin(t *testing.T) {
|
||||
t.Fatalf("HiddenRoot() = %q, want %q", got, "keepass")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHiddenRootFallsBackToEntryPathsWhenGroupsAreSparse(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
model := vault.Model{
|
||||
Entries: []vault.Entry{
|
||||
{ID: "rusty", Title: "Rusty GitLab", Path: []string{"keepass", "Joe", "Internet"}},
|
||||
},
|
||||
Groups: [][]string{
|
||||
{"Recycle Bin"},
|
||||
},
|
||||
}
|
||||
|
||||
if got := HiddenRoot(model); got != "keepass" {
|
||||
t.Fatalf("HiddenRoot() = %q, want %q", got, "keepass")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user