Apply review suggestions

This commit is contained in:
Shadowghost
2023-01-27 15:49:08 +01:00
parent 15efb9935c
commit 5cdb0c7932
4 changed files with 46 additions and 187 deletions

View File

@@ -297,30 +297,17 @@ namespace Emby.Server.Implementations.Localization
}
// Try splitting by : to handle "Germany: FSK 18"
var index = rating.IndexOf(':', StringComparison.Ordinal);
if (index != -1)
if (rating.Contains(':', StringComparison.OrdinalIgnoreCase))
{
var trimmedRating = rating.AsSpan(index).TrimStart(':').Trim();
if (!trimmedRating.IsEmpty)
{
return GetRatingLevel(trimmedRating.ToString());
}
return GetRatingLevel(rating.AsSpan().RightPart(':').ToString());
}
// Remove prefix country code to handle "DE-18"
index = rating.IndexOf('-', StringComparison.Ordinal);
if (index != -1)
if (rating.Contains('-', StringComparison.OrdinalIgnoreCase))
{
var trimmedRating = rating.AsSpan(index).TrimStart('-').Trim();
if (!trimmedRating.IsEmpty)
{
return GetRatingLevel(trimmedRating.ToString());
}
return GetRatingLevel(rating.AsSpan().RightPart('-').ToString());
}
// TODO: Further improve when necessary
return null;
}

View File

@@ -6,6 +6,6 @@ MG6,6
9,9
KNT,12
12,12
BE_14,14
14,14
16,16
18,18
1 AL 0
6 9 9
7 KNT 12
8 12 12
9 BE_14 14 14
10 16 16
11 18 18