From db4c9b56aec06b27c857613f08083efdc4770863 Mon Sep 17 00:00:00 2001 From: Hammad Aslam <36418598+haslam93@users.noreply.github.com> Date: Wed, 13 Aug 2025 13:47:18 -0400 Subject: [PATCH] Update controller.js --- api/controller.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api/controller.js b/api/controller.js index 949731c..f3a8f20 100644 --- a/api/controller.js +++ b/api/controller.js @@ -42,3 +42,10 @@ exports.calculate = function(req, res) { res.json({ result: operation(req.query.operand1, req.query.operand2) }); }; + +//Make a change + if (!req.query.operand2 || + !req.query.operand2.match(/^(-)?[0-9\.]+(e(-)?[0-9]+)?$/) || + req.query.operand2.replace(/[-0-9e]/g, '').length > 1) { + throw new Error("Invalid operand2: " + req.query.operand2); + }