Skip to content

Commit c8b3a18

Browse files
authored
we should not return the last item if there is no match (#892)
1 parent 9eff145 commit c8b3a18

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

blocks/flag.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ const flagBlock: Block<BlockModule<FlagFunc>> = {
7777
if (isMultivariate(flag)) {
7878
const value = ((flag?.variants ?? []).find((variant) =>
7979
typeof variant?.rule === "function" && variant?.rule(ctx)
80-
) as Variant<unknown>)?.value ??
81-
((flag?.variants ?? [])[flag?.variants?.length - 1] as Variant<unknown>)
82-
?.value;
80+
) as Variant<unknown>)?.value ?? null;
8381
return isDeferred(value) ? value() : value;
8482
}
8583
const matchValue = typeof flag?.matcher === "function"

0 commit comments

Comments
 (0)