diff --git a/src/pure.js b/src/pure.js index 25971ab..3226484 100644 --- a/src/pure.js +++ b/src/pure.js @@ -11,15 +11,12 @@ export function parseTarget(input) { if (typeof input !== 'string') return null; const cleaned = input.replace(/,/g, '').trim().toLowerCase(); - if (cleaned === '') return null; - - // Reject anything other than digits, optional decimal, and optional single trailing suffix letter - if (!/^\d+(\.\d+)?[kmbt]?$/.test(cleaned)) return null; const match = cleaned.match(/^(\d+(?:\.\d+)?)([kmbt])?$/); if (!match) return null; const num = parseFloat(match[1]); + // regex permits '0'; reject it if (!Number.isFinite(num) || num <= 0) return null; const suffix = match[2]; diff --git a/tests/pure.test.js b/tests/pure.test.js index 957d1be..5683659 100644 --- a/tests/pure.test.js +++ b/tests/pure.test.js @@ -30,4 +30,5 @@ test('parseTarget: rejects invalid input', () => { assert.equal(parseTarget(undefined), null); assert.equal(parseTarget('25M.5'), null); assert.equal(parseTarget('1.5.5M'), null); + assert.equal(parseTarget('0'), null); });