stop supporting prefix matches.
This commit is contained in:
@@ -45,7 +45,7 @@ func (ef Filter) Matches(event *Event) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if ef.IDs != nil && !containsPrefixOf(ef.IDs, event.ID) {
|
if ef.IDs != nil && !slices.Contains(ef.IDs, event.ID) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ func (ef Filter) Matches(event *Event) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if ef.Authors != nil && !containsPrefixOf(ef.Authors, event.PubKey) {
|
if ef.Authors != nil && !slices.Contains(ef.Authors, event.PubKey) {
|
||||||
return false
|
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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if ef.Until != nil && event.CreatedAt > *ef.Until {
|
if ef.Until != nil && event.CreatedAt >= *ef.Until {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
9
utils.go
9
utils.go
@@ -28,15 +28,6 @@ func similar[E constraints.Ordered](as, bs []E) bool {
|
|||||||
return true
|
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.
|
// Escaping strings for JSON encoding according to RFC8259.
|
||||||
// Also encloses result in quotation marks "".
|
// Also encloses result in quotation marks "".
|
||||||
func escapeString(dst []byte, s string) []byte {
|
func escapeString(dst []byte, s string) []byte {
|
||||||
|
|||||||
Reference in New Issue
Block a user