Module:Convert: Difference between revisions

fix valid_number check to account for Scribunto using 'nan' or 'inf' for problem numbers
(allow conversion between different unit types for certain whitelisted exceptions (torque/energy); emulate MediaWiki's template handling by accepting   and multiple spaces in a unit name)
(fix valid_number check to account for Scribunto using 'nan' or 'inf' for problem numbers)
Line 639:
local function valid_number(num)
-- Return true if num is a valid number.
-- In Scribunto (different from some standard Lua), when expressed as a string,
-- Expressed as a string, overflow or other problems are indicated with
-- overflow or other problems are indicated with text like "1.#INFinf" or ".#INDnan" which are regarded as invalid here.
-- which are regarded as invalid here (each contains "n").
if type(num) == 'number' and tostring(num):find('#n', 1, true) == nil then
return true
end
Anonymous user