Return string.Empty is span IsEmpty

pull/8381/head
1hitsong 2 years ago
parent 97409adb45
commit 563d5fb5d9

@ -201,11 +201,13 @@ public class LrcLyricProvider : ILyricProvider
private static string GetMetadataFieldName(string metaDataRow, int index) private static string GetMetadataFieldName(string metaDataRow, int index)
{ {
return metaDataRow.AsSpan(1, index - 1).Trim().ToString(); var metadataFieldName = metaDataRow.AsSpan(1, index - 1).Trim();
return metadataFieldName.IsEmpty ? string.Empty : metadataFieldName.ToString();
} }
private static string GetMetadataValue(string metaDataRow, int index) private static string GetMetadataValue(string metaDataRow, int index)
{ {
return metaDataRow.AsSpan(index + 1, metaDataRow.Length - index - 2).Trim().ToString(); var metadataValue = metaDataRow.AsSpan(index + 1, metaDataRow.Length - index - 2).Trim();
return metadataValue.IsEmpty ? string.Empty : metadataValue.ToString();
} }
} }

@ -48,9 +48,9 @@ public class TxtLyricProvider : ILyricProvider
LyricLine[] lyricList = new LyricLine[lyricTextLines.Length]; LyricLine[] lyricList = new LyricLine[lyricTextLines.Length];
for (int lyricLine = 0; lyricLine < lyricTextLines.Length; lyricLine++) for (int lyricLineIndex = 0; lyricLineIndex < lyricTextLines.Length; lyricLineIndex++)
{ {
lyricList[lyricLine] = new LyricLine(lyricTextLines[lyricLine]); lyricList[lyricLineIndex] = new LyricLine(lyricTextLines[lyricLineIndex]);
} }
return new LyricResponse { Lyrics = lyricList }; return new LyricResponse { Lyrics = lyricList };

Loading…
Cancel
Save