Update src/Terminal/commands/expr.ts

Updated to ApamNapat's suggestion

Co-authored-by: ApamNapat <ApamNapat@users.noreply.github.com>
This commit is contained in:
mbrannen 2022-03-08 18:02:54 -07:00 committed by GitHub
parent bb6d90fb41
commit 9602dbda2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -17,7 +17,7 @@ export function expr(
const expr = args.join(""); const expr = args.join("");
// Sanitize the math expression // Sanitize the math expression
const sanitizedExpr = expr.replace(/s+/g, "").replace(/[^-()\d*/+.\%]/g, ""); const sanitizedExpr = expr.replace(/s+/g, "").replace(/[^-()\d/*+.%]/g, "");
let result; let result;
try { try {
result = eval(sanitizedExpr); result = eval(sanitizedExpr);