CLI: Allow using E notation in expr CLI (#2209)

This commit is contained in:
catloversg
2025-06-21 01:12:37 +07:00
committed by GitHub
parent 18f84396e2
commit 5ac327697b

View File

@@ -8,7 +8,7 @@ export function expr(args: (string | number | boolean)[]): void {
const expr = args.join("");
// Sanitize the math expression
const sanitizedExpr = expr.replace(/[^-()\d/*+.%]/g, "");
const sanitizedExpr = expr.replace(/[^-()\deE/*+.%]/g, "");
let result: string;
try {
result = String(eval?.(sanitizedExpr));