Merge pull request #5138 from ivandrofly/continuation-utilities

fix zero length string replace
This commit is contained in:
Nikolaj Olsson 2021-06-20 13:46:55 +02:00 committed by GitHub
commit 90a8ec740b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -670,7 +670,7 @@ namespace Nikse.SubtitleEdit.Core.Common
}
newFirstWord = newFirstWord.Trim();
string result;
string result = null;
// If we can find it...
if (originalText.IndexOf(firstWord, StringComparison.Ordinal) >= 0)
@ -678,7 +678,7 @@ namespace Nikse.SubtitleEdit.Core.Common
// Replace it
result = ReplaceFirstOccurrence(originalText, firstWord, newFirstWord);
}
else
else if (newFirstWord.Length > 0)
{
// Just remove whatever prefix we need to remove
var prefix = firstWord.Replace(newFirstWord, "");