diff --git a/filter.go b/filter.go index c84a401..9ff2c06 100644 --- a/filter.go +++ b/filter.go @@ -45,7 +45,7 @@ func (ef Filter) Matches(event *Event) bool { return false } - if ef.IDs != nil && !containsPrefixOf(ef.IDs, event.ID) { + if ef.IDs != nil && !slices.Contains(ef.IDs, event.ID) { return false } @@ -53,7 +53,7 @@ func (ef Filter) Matches(event *Event) bool { return false } - if ef.Authors != nil && !containsPrefixOf(ef.Authors, event.PubKey) { + if ef.Authors != nil && !slices.Contains(ef.Authors, event.PubKey) { return false } @@ -63,11 +63,11 @@ func (ef Filter) Matches(event *Event) bool { } } - if ef.Since != nil && event.CreatedAt < *ef.Since { + if ef.Since != nil && event.CreatedAt <= *ef.Since { return false } - if ef.Until != nil && event.CreatedAt > *ef.Until { + if ef.Until != nil && event.CreatedAt >= *ef.Until { return false } diff --git a/utils.go b/utils.go index 7b626a2..cdeeae5 100644 --- a/utils.go +++ b/utils.go @@ -28,15 +28,6 @@ func similar[E constraints.Ordered](as, bs []E) bool { return true } -func containsPrefixOf(haystack []string, needle string) bool { - for _, hay := range haystack { - if strings.HasPrefix(needle, hay) { - return true - } - } - return false -} - // Escaping strings for JSON encoding according to RFC8259. // Also encloses result in quotation marks "". func escapeString(dst []byte, s string) []byte {