summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2022-01-13 20:24:53 -0500
committerLinus Groh <mail@linusgroh.de>2022-01-14 11:12:24 +0100
commitdb869a04022c484a57315a15f64deea6956ba7f4 (patch)
tree37ecd04b534c5a3875c744556bc7493985c65471 /Userland
parent1b944b4c41321c1180b175a257674a9679a0b88a (diff)
downloadserenity-db869a04022c484a57315a15f64deea6956ba7f4.zip
LibJS: Add an else in StringPrototype::substr
No behavior change, but makes the code look more like the spec test for this function.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibJS/Runtime/StringPrototype.cpp2
1 files changed, 1 insertions, 1 deletions
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);