Commit 6d85c42f authored by Pierre Ynard's avatar Pierre Ynard

luahttp: make rounding function resilient to strings

Because somehow strings are used to represent decimals...

Fixes #6815
(cherry picked from commit 78ee8bbd0478fda7ff55f8aa0d0a051be6784248)
Signed-off-by: default avatarPierre Ynard <linkfanel@yahoo.fr>
parent c84bdbdc
......@@ -31,7 +31,13 @@ local dkjson = require ("dkjson")
--Round the number to the specified precision
function round(what, precision)
if what then return math.floor(what*math.pow(10,precision)+0.5) / math.pow(10,precision) else return "" end
if type(what) == "string" then
what = common.us_tonumber(what)
end
if type(what) == "number" then
return math.floor(what*math.pow(10,precision)+0.5) / math.pow(10,precision)
end
return nil
end
--split text where it matches the delimiter
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment