mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +00:00
LibJS: Trim whitespace from string before coercing to number
This commit is contained in:
committed by
Andreas Kling
parent
f39c7c2978
commit
de42ddfd93
@@ -165,8 +165,7 @@ Value Value::to_number() const
|
||||
case Type::Number:
|
||||
return Value(m_value.as_double);
|
||||
case Type::String: {
|
||||
// FIXME: Trim whitespace beforehand
|
||||
auto& string = as_string().string();
|
||||
auto string = as_string().string().trim_whitespace();
|
||||
if (string.is_empty())
|
||||
return Value(0);
|
||||
if (string == "Infinity" || string == "+Infinity")
|
||||
|
||||
Reference in New Issue
Block a user