fix: fall back to example addresses in summary preview - #303
Conversation
tony8713
left a comment
There was a problem hiding this comment.
LGTM. Confirmed the bug: [customParams.id] || constants.example.addresses always short-circuits to [customParams.id] because a non-empty array literal is always truthy, so with no ?id= query param the summary preview rendered with [undefined] instead of the example address. The ternary fixes it correctly and the empty-string case (?id=) now also falls back to the examples, which is the right behavior.
Verified against src/preview/index.ts (id: req.query.id) — this only affects the auth-gated dev preview endpoint, no runtime notification path touched. Nicely scoped out of the eslint/prettier PRs.
Not blocking, just noting: a repeated ?id=a&id=b query param would make req.query.id an array and produce a nested [['a','b']], but that's a pre-existing degenerate input to a dev-only tool and out of scope here.
Summary
The previous
[customParams.id] || constants.example.addressesexpression never reached the fallback because an array is always truthy.Checks