From db869a04022c484a57315a15f64deea6956ba7f4 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Thu, 13 Jan 2022 20:24:53 -0500 Subject: [PATCH] LibJS: Add an else in StringPrototype::substr No behavior change, but makes the code look more like the spec test for this function. --- Userland/Libraries/LibJS/Runtime/StringPrototype.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp index fbf917f126..96da205c09 100644 --- a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp @@ -517,7 +517,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::substr) auto int_start = TRY(vm.argument(0).to_integer_or_infinity(global_object)); if (Value(int_start).is_negative_infinity()) int_start = 0; - if (int_start < 0) + else if (int_start < 0) int_start = max(size + int_start, 0); auto length = vm.argument(1);