From 896163470d73d719787a15c55188873313e33dc0 Mon Sep 17 00:00:00 2001 From: Campbell Alden Date: Sun, 22 Mar 2026 00:23:02 +0900 Subject: [PATCH] Accept arbitrarily formatted numbers as the amount input --- reporter.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/reporter.js b/reporter.js index 6b4642d..bdae535 100644 --- a/reporter.js +++ b/reporter.js @@ -21,9 +21,15 @@ function parse(data) { throw new Error('Bad Title'); } - if (typeof data.amount !== 'number') { + if (typeof data.amount !== 'number' || typeof data.amount !== 'string') { throw new Error('Bad amount'); } + + if (typeof data.amount === 'string') { + const value = Number(data.amount.replaceAll(/[^\d]/g, '')); + data.amount = Number.isNaN(value) ? 0 : value; + } + return data; }