Skip to content

Commit

Permalink
fix(plugin-server): filter NaN out of buildIntegerMatcher (PostHog#18106
Browse files Browse the repository at this point in the history
)
  • Loading branch information
bretthoerner authored and Justicea83 committed Oct 24, 2023
1 parent d0fc30b commit b0a5223
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions plugin-server/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,19 @@ export function overrideWithEnv(
}

export function buildIntegerMatcher(config: string | undefined, allowStar: boolean): ValueMatcher<number> {
// Builds a ValueMatcher on a coma-separated list of values.
// Builds a ValueMatcher on a comma-separated list of values.
// Optionally, supports a '*' value to match everything
if (!config) {
if (!config || config.trim().length == 0) {
return () => false
} else if (allowStar && config === '*') {
return () => true
} else {
const values = new Set(config.split(',').map((n) => parseInt(n)))
const values = new Set(
config
.split(',')
.map((n) => parseInt(n))
.filter((num) => !isNaN(num))
)
return (v: number) => {
return values.has(v)
}
Expand Down

0 comments on commit b0a5223

Please sign in to comment.