mirror of
https://github.com/nbd-wtf/go-nostr.git
synced 2025-03-17 21:32:56 +01:00
stop supporting prefix matches.
This commit is contained in:
parent
35faff858a
commit
017816e3dc
@ -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
|
||||
}
|
||||
|
||||
|
9
utils.go
9
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user