Describe the bug
In src/helpers/speakerCount.js:
normalizeStoredSpeakerCount(value) converts its input using const count = Number(value) and checks Number.isInteger(count) && count >= 1.
In JavaScript:
Number(true) is 1, so normalizeStoredSpeakerCount(true) returns 1.
Number(["2"]) is 2, so normalizeStoredSpeakerCount(["2"]) returns 2.
When non-numeric types (such as booleans or arrays) arrive via cloud sync or loosely structured stored data, normalizeStoredSpeakerCount erroneously returns an integer instead of degrading to null.
To Reproduce
- Call
normalizeStoredSpeakerCount(true) -> returns 1 (expected null).
- Call
normalizeStoredSpeakerCount(["2"]) -> returns 2 (expected null).
Expected Behavior
normalizeStoredSpeakerCount should only accept numbers or numeric strings (typeof value === "number" || typeof value === "string"), returning null for booleans, arrays, and other non-numeric types.
Describe the bug
In
src/helpers/speakerCount.js:normalizeStoredSpeakerCount(value)converts its input usingconst count = Number(value)and checksNumber.isInteger(count) && count >= 1.In JavaScript:
Number(true)is1, sonormalizeStoredSpeakerCount(true)returns1.Number(["2"])is2, sonormalizeStoredSpeakerCount(["2"])returns2.When non-numeric types (such as booleans or arrays) arrive via cloud sync or loosely structured stored data,
normalizeStoredSpeakerCounterroneously returns an integer instead of degrading tonull.To Reproduce
normalizeStoredSpeakerCount(true)-> returns1(expectednull).normalizeStoredSpeakerCount(["2"])-> returns2(expectednull).Expected Behavior
normalizeStoredSpeakerCountshould only accept numbers or numeric strings (typeof value === "number" || typeof value === "string"), returningnullfor booleans, arrays, and other non-numeric types.