Fix String.ends_with() for empty string arguments
This commit is contained in:
parent
7dea83c623
commit
1d0437c95b
1 changed files with 6 additions and 1 deletions
|
@ -3074,11 +3074,16 @@ 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 = rfind(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 {
|
||||
|
|
Loading…
Reference in a new issue