getFilterLimit: empty tags return 0

This commit is contained in:
Alex Gleason
2024-05-30 12:55:39 -05:00
committed by fiatjaf_
parent 87a91c2daf
commit f8c3e20f3d
2 changed files with 8 additions and 0 deletions

View File

@@ -78,6 +78,10 @@ export function getFilterLimit(filter: Filter): number {
if (filter.kinds && !filter.kinds.length) return 0
if (filter.authors && !filter.authors.length) return 0
for (const [key, value] of Object.entries(filter)) {
if (key[0] === '#' && Array.isArray(value) && !value.length) return 0
}
return Math.min(
Math.max(0, filter.limit ?? Infinity),
filter.ids?.length ?? Infinity,