LibJS: Parse digits with parse_ascii_base36_digit in parseInt

This was accidentally replaced with parse_ascii_hex_digit in
bc8d16ad28 which caused radices above
16 (hex) to fail.
This commit is contained in:
Idan Horowitz 2021-06-06 02:29:29 +03:00 committed by Linus Groh
commit bda32e9440
Notes: sideshowbarker 2024-07-18 14:29:49 +09:00

View file

@ -251,9 +251,9 @@ JS_DEFINE_NATIVE_FUNCTION(GlobalObject::parse_int)
}
auto parse_digit = [&](u32 code_point, i32 radix) -> Optional<i32> {
if (!is_ascii_hex_digit(code_point) || radix <= 0)
if (!is_ascii_alphanumeric(code_point) || radix <= 0)
return {};
auto digit = parse_ascii_hex_digit(code_point);
auto digit = parse_ascii_base36_digit(code_point);
if (digit >= (u32)radix)
return {};
return digit;