Merge pull request #5406 from cvium/trycleanstring-dont-die-on-me
This commit is contained in:
commit
0ef8bea125
|
@ -33,6 +33,12 @@ namespace Emby.Naming.Video
|
||||||
|
|
||||||
private static bool TryClean(string name, Regex expression, out ReadOnlySpan<char> newName)
|
private static bool TryClean(string name, Regex expression, out ReadOnlySpan<char> newName)
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(name))
|
||||||
|
{
|
||||||
|
newName = ReadOnlySpan<char>.Empty;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
var match = expression.Match(name);
|
var match = expression.Match(name);
|
||||||
int index = match.Index;
|
int index = match.Index;
|
||||||
if (match.Success && index != 0)
|
if (match.Success && index != 0)
|
||||||
|
@ -41,7 +47,7 @@ namespace Emby.Naming.Video
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
newName = string.Empty;
|
newName = ReadOnlySpan<char>.Empty;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ namespace Jellyfin.Naming.Tests.Video
|
||||||
[InlineData("Crouching.Tiger.Hidden.Dragon.BDrip.mkv", "Crouching.Tiger.Hidden.Dragon")]
|
[InlineData("Crouching.Tiger.Hidden.Dragon.BDrip.mkv", "Crouching.Tiger.Hidden.Dragon")]
|
||||||
[InlineData("Crouching.Tiger.Hidden.Dragon.BDrip-HDC.mkv", "Crouching.Tiger.Hidden.Dragon")]
|
[InlineData("Crouching.Tiger.Hidden.Dragon.BDrip-HDC.mkv", "Crouching.Tiger.Hidden.Dragon")]
|
||||||
[InlineData("Crouching.Tiger.Hidden.Dragon.4K.UltraHD.HDR.BDrip-HDC.mkv", "Crouching.Tiger.Hidden.Dragon")]
|
[InlineData("Crouching.Tiger.Hidden.Dragon.4K.UltraHD.HDR.BDrip-HDC.mkv", "Crouching.Tiger.Hidden.Dragon")]
|
||||||
|
[InlineData(null, null)]
|
||||||
// FIXME: [InlineData("After The Sunset - [0004].mkv", "After The Sunset")]
|
// FIXME: [InlineData("After The Sunset - [0004].mkv", "After The Sunset")]
|
||||||
public void CleanStringTest(string input, string expectedName)
|
public void CleanStringTest(string input, string expectedName)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user