Skip to content

Commit

Permalink
Fix(hop): filter number issue (#11)
Browse files Browse the repository at this point in the history
small hotfix to handle cases where there's a type mismatch between string/bigint/number for number typed keys and values in the filter.

---------

Co-authored-by: Quazia <[email protected]>
  • Loading branch information
Quazia and Quazia authored Sep 7, 2023
1 parent 95ed60d commit 46d2937
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/filter/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ export function apply(

for (const key in filters) {
if (!Object.hasOwnProperty.call(filters, key)) continue

if (key in preprocessors) {
context = preprocessors[key as PreprocessorKey](context, filters)
continue
Expand All @@ -248,6 +247,15 @@ export function apply(
if (context[key].toLowerCase() !== filters[key].toLowerCase()) {
return false
}
} else if (
typeof filters[key] === 'bigint' ||
typeof filters[key] === 'number' ||
typeof context[key] === 'bigint' ||
typeof context[key] === 'number'
) {
if (BigInt(context[key]) !== BigInt(filters[key])) {
return false
}
} else if (context[key] !== filters[key]) {
return false
}
Expand Down

0 comments on commit 46d2937

Please sign in to comment.