diff --git a/.eslintrc.js b/.eslintrc.js index 9e80f9a..81bee71 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,7 +3,7 @@ module.exports = { "browser": true, "es2021": true, "mocha": true, - "request": true + "node": true }, "extends": "eslint:recommended", "overrides": [ @@ -13,5 +13,9 @@ module.exports = { "sourceType": "module" }, "rules": { + }, + "globals": { + "expect": true, + "request": true } } diff --git a/api/controller.js b/api/controller.js index 949731c..797d0f7 100644 --- a/api/controller.js +++ b/api/controller.js @@ -29,13 +29,13 @@ exports.calculate = function(req, res) { } if (!req.query.operand1 || - !req.query.operand1.match(/^(-)?[0-9\.]+(e(-)?[0-9]+)?$/) || + !req.query.operand1.match(/^(-)?[0-9.]+(e(-)?[0-9]+)?$/) || req.query.operand1.replace(/[-0-9e]/g, '').length > 1) { throw new Error("Invalid operand1: " + req.query.operand1); } if (!req.query.operand2 || - !req.query.operand2.match(/^(-)?[0-9\.]+(e(-)?[0-9]+)?$/) || + !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); }