Fix IndexOf bug in CreateBucketId (#2948)

Fix IndexOf bug in CreateBucketId
This commit is contained in:
Tine
2024-07-01 00:09:03 +07:00
committed by GitHub
parent 8afea2c09d
commit ec0ba49dba

View File

@@ -2705,14 +2705,14 @@ namespace Discord.API
int lastIndex = 0; int lastIndex = 0;
while (true) while (true)
{ {
int leftIndex = format.IndexOf("{", lastIndex); int leftIndex = format.IndexOf('{', lastIndex);
if (leftIndex == -1 || leftIndex > endIndex) if (leftIndex == -1 || leftIndex > endIndex)
{ {
builder.Append(format, lastIndex, endIndex - lastIndex); builder.Append(format, lastIndex, endIndex - lastIndex);
break; break;
} }
builder.Append(format, lastIndex, leftIndex - lastIndex); builder.Append(format, lastIndex, leftIndex - lastIndex);
int rightIndex = format.IndexOf("}", leftIndex); int rightIndex = format.IndexOf('}', leftIndex);
int argId = int.Parse(format.Substring(leftIndex + 1, rightIndex - leftIndex - 1), NumberStyles.None, CultureInfo.InvariantCulture); int argId = int.Parse(format.Substring(leftIndex + 1, rightIndex - leftIndex - 1), NumberStyles.None, CultureInfo.InvariantCulture);
string fieldName = GetFieldName(methodArgs[argId + 1]); string fieldName = GetFieldName(methodArgs[argId + 1]);