mirror of
https://github.com/hoytech/strfry.git
synced 2025-06-17 08:48:51 +00:00
allow filtering on empty tag values
This commit is contained in:
@ -49,8 +49,6 @@ struct FilterSetBytes {
|
||||
}
|
||||
|
||||
bool doesMatch(std::string_view candidate) const {
|
||||
if (candidate.size() == 0) throw herr("invalid candidate");
|
||||
|
||||
// Binary search for upper-bound: https://en.cppreference.com/w/cpp/algorithm/upper_bound
|
||||
|
||||
ssize_t first = 0, last = items.size(), curr;
|
||||
@ -61,7 +59,7 @@ struct FilterSetBytes {
|
||||
step = count / 2;
|
||||
curr += step;
|
||||
|
||||
bool comp = (uint8_t)candidate[0] != items[curr].firstByte
|
||||
bool comp = (candidate.size() && items[curr].size && (uint8_t)candidate[0] != items[curr].firstByte)
|
||||
? (uint8_t)candidate[0] < items[curr].firstByte
|
||||
: candidate < std::string_view(buf.data() + items[curr].offset, items[curr].size);
|
||||
|
||||
@ -145,7 +143,7 @@ struct NostrFilter {
|
||||
if (tag == 'p' || tag == 'e') {
|
||||
tags.emplace(tag, FilterSetBytes(v, true, 32, 32));
|
||||
} else {
|
||||
tags.emplace(tag, FilterSetBytes(v, false, 1, MAX_INDEXED_TAG_VAL_SIZE));
|
||||
tags.emplace(tag, FilterSetBytes(v, false, 0, MAX_INDEXED_TAG_VAL_SIZE));
|
||||
}
|
||||
} else {
|
||||
throw herr("unindexed tag filter");
|
||||
|
Reference in New Issue
Block a user