Files
phishingclub/backend/vendor/github.com/enetx/surf/cookies.go
T
Ronni Skansing 07c8adaf76 update vendor deps
Signed-off-by: Ronni Skansing <rskansing@gmail.com>
2025-11-06 23:31:08 +01:00

37 lines
813 B
Go

package surf
import (
"regexp"
"github.com/enetx/g"
"github.com/enetx/http"
)
// Cookies represents a list of HTTP Cookies.
type Cookies []*http.Cookie
// Contains checks if the cookies collection contains a cookie that matches the provided pattern.
// The pattern parameter can be either a string or a pointer to a regexp.Regexp object.
// The method returns true if a matching cookie is found and false otherwise.
func (cs *Cookies) Contains(pattern any) bool {
for _, cookie := range *cs {
c := g.String(cookie.String()).Lower()
switch p := pattern.(type) {
case string:
if c.Contains(g.String(p).Lower()) {
return true
}
case g.String:
if c.Contains(p.Lower()) {
return true
}
case *regexp.Regexp:
if c.Regexp().Match(p) {
return true
}
}
}
return false
}