You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2026-01-06 19:41:11 +00:00
Fix String.ends_with() for empty string arguments
(cherry picked from commit 1d0437c95b)
This commit is contained in:
committed by
Rémi Verschelde
parent
6cc6dce9c1
commit
39cf22a9c7
@@ -2709,10 +2709,15 @@ int String::rfindn(const String &p_str, int p_from) const {
|
||||
|
||||
bool String::ends_with(const String &p_string) const {
|
||||
|
||||
int l = p_string.length();
|
||||
if (l == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int pos = find_last(p_string);
|
||||
if (pos == -1)
|
||||
return false;
|
||||
return pos + p_string.length() == length();
|
||||
return pos + l == length();
|
||||
}
|
||||
|
||||
bool String::begins_with(const String &p_string) const {
|
||||
|
||||
Reference in New Issue
Block a user