diff --git a/AK/String.cpp b/AK/String.cpp index 333a92d0679..f5b3f69eafd 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -491,14 +491,24 @@ bool String::contains(char needle, CaseSensitivity case_sensitivity) const return contains(StringView { &needle, 1 }, case_sensitivity); } +bool String::starts_with(u32 code_point) const +{ + return bytes_as_string_view().starts_with(code_point); +} + bool String::starts_with_bytes(StringView bytes) const { return bytes_as_string_view().starts_with(bytes); } -bool String::starts_with(u32 code_point) const +bool String::ends_with(u32 code_point) const { - return bytes_as_string_view().starts_with(code_point); + return bytes_as_string_view().ends_with(code_point); +} + +bool String::ends_with_bytes(StringView bytes) const +{ + return bytes_as_string_view().ends_with(bytes); } bool String::is_short_string() const diff --git a/AK/String.h b/AK/String.h index 9b46a08d626..45ac7a99fcf 100644 --- a/AK/String.h +++ b/AK/String.h @@ -112,6 +112,9 @@ public: bool starts_with(u32 code_point) const; bool starts_with_bytes(StringView) const; + bool ends_with(u32 code_point) const; + bool ends_with_bytes(StringView) const; + // Creates a substring with a deep copy of the specified data window. ErrorOr substring_from_byte_offset(size_t start, size_t byte_count) const; ErrorOr substring_from_byte_offset(size_t start) const;