Skip to content

Commit

Permalink
filter: stop matching against id and pubkey prefixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed May 19, 2024
1 parent f4f9bec commit 44efd49
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ export type Filter = {

export function matchFilter(filter: Filter, event: Event): boolean {
if (filter.ids && filter.ids.indexOf(event.id) === -1) {
if (!filter.ids.some(prefix => event.id.startsWith(prefix))) {
return false
}
return false
}
if (filter.kinds && filter.kinds.indexOf(event.kind) === -1) {
return false
}
if (filter.kinds && filter.kinds.indexOf(event.kind) === -1) return false
if (filter.authors && filter.authors.indexOf(event.pubkey) === -1) {
if (!filter.authors.some(prefix => event.pubkey.startsWith(prefix))) {
return false
}
return false
}

for (let f in filter) {
Expand Down

0 comments on commit 44efd49

Please sign in to comment.