这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,6 @@ func (f FilterFunc) Filter(c *Cookie) bool {
return f(c)
}

type ValueFilterFunc func(*Cookie) bool

func (f ValueFilterFunc) Filter(c *Cookie) bool {
if f == nil {
return false
}
return f(c)
}

// FilterCookies() applies "filters" in order to the "cookies".
func FilterCookies[T Cookie | http.Cookie](cookies []*T, filters ...Filter) []*T {
var ret = make([]*T, 0, len(cookies))
Expand Down Expand Up @@ -197,34 +188,6 @@ func PathDepth(depth int) Filter {
})
}

// value filters

func Value(value string) Filter {
return ValueFilterFunc(func(cookie *Cookie) bool {
return cookie != nil && cookie.Value == value
})
}
func ValueContains(substr string) Filter {
return ValueFilterFunc(func(cookie *Cookie) bool {
return cookie != nil && strings.Contains(cookie.Value, substr)
})
}
func ValueHasPrefix(prefix string) Filter {
return ValueFilterFunc(func(cookie *Cookie) bool {
return cookie != nil && strings.HasPrefix(cookie.Value, prefix)
})
}
func ValueHasSuffix(suffix string) Filter {
return ValueFilterFunc(func(cookie *Cookie) bool {
return cookie != nil && strings.HasSuffix(cookie.Value, suffix)
})
}
func ValueLen(length int) Filter {
return ValueFilterFunc(func(cookie *Cookie) bool {
return cookie != nil && len(cookie.Value) == length
})
}

// secure filter

var Secure Filter = FilterFunc(func(cookie *Cookie) bool {
Expand Down
13 changes: 0 additions & 13 deletions internal/chrome/chrome.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,6 @@ func (s *CookieStore) ReadCookies(filters ...kooky.Filter) ([]*kooky.Cookie, err
"secure": "is_secure",
"httponly": "is_httponly",
}
hasValueFilter := false
for _, filter := range filters {
if _, ok := filter.(kooky.ValueFilterFunc); ok {
hasValueFilter = true
break
}
}
err := utils.VisitTableRows(s.Database, `cookies`, headerMappings, func(rowID *int64, row utils.TableRow) error {
cookie := &kooky.Cookie{
Creation: timex.FromFILETIME(*rowID * 10),
Expand Down Expand Up @@ -83,12 +76,6 @@ func (s *CookieStore) ReadCookies(filters ...kooky.Filter) ([]*kooky.Cookie, err
return err
}

if hasValueFilter {
if err := getCookieValue(s, cookie, row); err != nil {
return err
}
}

if kooky.FilterCookie(cookie, filters...) {
cookies = append(cookies, cookie)
}
Expand Down