aboutsummaryrefslogtreecommitdiff
path: root/Emby.Naming/Video/CleanStringParser.cs
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2021-08-18 02:46:59 -0400
committerGitHub <noreply@github.com>2021-08-18 02:46:59 -0400
commit72d3f7020ad80ce1a53eeae8c5d57abeb22a4679 (patch)
treedd43e663838cdc7d99a4af565523df58ae23c856 /Emby.Naming/Video/CleanStringParser.cs
parent7aef0fce444e6d8e06386553ec7ea1401a01bbb1 (diff)
parente5cbafdb6b47377052e0d638908ef96e30a997d6 (diff)
Merge branch 'master' into patch-2
Diffstat (limited to 'Emby.Naming/Video/CleanStringParser.cs')
-rw-r--r--Emby.Naming/Video/CleanStringParser.cs21
1 files changed, 16 insertions, 5 deletions
diff --git a/Emby.Naming/Video/CleanStringParser.cs b/Emby.Naming/Video/CleanStringParser.cs
index 3f584d5847..4eef3ebc5e 100644
--- a/Emby.Naming/Video/CleanStringParser.cs
+++ b/Emby.Naming/Video/CleanStringParser.cs
@@ -1,8 +1,6 @@
-#pragma warning disable CS1591
-#nullable enable
-
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Text.RegularExpressions;
namespace Emby.Naming.Video
@@ -12,8 +10,21 @@ namespace Emby.Naming.Video
/// </summary>
public static class CleanStringParser
{
- public static bool TryClean(string name, IReadOnlyList<Regex> expressions, out ReadOnlySpan<char> newName)
+ /// <summary>
+ /// Attempts to extract clean name with regular expressions.
+ /// </summary>
+ /// <param name="name">Name of file.</param>
+ /// <param name="expressions">List of regex to parse name and year from.</param>
+ /// <param name="newName">Parsing result string.</param>
+ /// <returns>True if parsing was successful.</returns>
+ public static bool TryClean([NotNullWhen(true)] string? name, IReadOnlyList<Regex> expressions, out ReadOnlySpan<char> newName)
{
+ if (string.IsNullOrEmpty(name))
+ {
+ newName = ReadOnlySpan<char>.Empty;
+ return false;
+ }
+
var len = expressions.Count;
for (int i = 0; i < len; i++)
{
@@ -37,7 +48,7 @@ namespace Emby.Naming.Video
return true;
}
- newName = string.Empty;
+ newName = ReadOnlySpan<char>.Empty;
return false;
}
}