stop supporting prefix matches.

This commit is contained in:
fiatjaf 2023-08-05 10:12:57 -03:00
parent 35faff858a
commit 017816e3dc
No known key found for this signature in database
GPG Key ID: BAD43C4BE5C1A3A1
2 changed files with 4 additions and 13 deletions

View File

@ -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
}

View File

@ -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 {