mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 14:07:45 +00:00
LibJS: Trim all types of whitespace characters before parsing numbers
This commit is contained in:
parent
232e830a0a
commit
60bc5e3b5b
3 changed files with 3 additions and 2 deletions
|
@ -31,6 +31,7 @@
|
|||
#include <LibJS/Runtime/ProxyObject.h>
|
||||
#include <LibJS/Runtime/RegExpObject.h>
|
||||
#include <LibJS/Runtime/StringObject.h>
|
||||
#include <LibJS/Runtime/StringPrototype.h>
|
||||
#include <LibJS/Runtime/SymbolObject.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
@ -476,7 +477,7 @@ ThrowCompletionOr<Value> Value::to_number(GlobalObject& global_object) const
|
|||
case Type::Double:
|
||||
return *this;
|
||||
case Type::String: {
|
||||
auto string = as_string().string().trim_whitespace();
|
||||
String string = Utf8View(as_string().string()).trim(whitespace_characters, AK::TrimMode::Both).as_string();
|
||||
if (string.is_empty())
|
||||
return Value(0);
|
||||
if (string == "Infinity" || string == "+Infinity")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue