1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:27:35 +00:00

Add a Chomp feature to String construction that removes a trailing newline.

This will be useful in many situations.
This commit is contained in:
Andreas Kling 2018-11-07 00:19:35 +01:00
parent 90bab5ea71
commit 8135952832
4 changed files with 19 additions and 9 deletions

View file

@ -65,6 +65,8 @@ Vector<String> String::split(const char separator) const
size_t taillen = length() - substart;
if (taillen != 0)
v.append(substring(substart, taillen));
if (characters()[length() - 1] == separator)
v.append(empty());
return v;
}