aboutsummaryrefslogtreecommitdiff
path: root/Emby.Naming/Video/CleanStringParser.cs
diff options
context:
space:
mode:
authorBaronGreenback <jimcartlidge@yahoo.co.uk>2021-03-22 17:05:44 +0000
committerGitHub <noreply@github.com>2021-03-22 17:05:44 +0000
commit5d16d1f66de499022da3eeb484a2cdfe341bed2f (patch)
treeac348fc960f2c849d989a6d2f27a34a73d4f3675 /Emby.Naming/Video/CleanStringParser.cs
parent7fa525c83b7573e61124fa1c64a3b27569e66b6d (diff)
parent0853d1265c99a2e8614aa0c7a584dff541484e19 (diff)
Merge branch 'master' into RemoteAccessFix
Diffstat (limited to 'Emby.Naming/Video/CleanStringParser.cs')
-rw-r--r--Emby.Naming/Video/CleanStringParser.cs15
1 files changed, 8 insertions, 7 deletions
diff --git a/Emby.Naming/Video/CleanStringParser.cs b/Emby.Naming/Video/CleanStringParser.cs
index bd7553a91..4eef3ebc5 100644
--- a/Emby.Naming/Video/CleanStringParser.cs
+++ b/Emby.Naming/Video/CleanStringParser.cs
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics.CodeAnalysis;
using System.Text.RegularExpressions;
namespace Emby.Naming.Video
@@ -16,8 +17,14 @@ namespace Emby.Naming.Video
/// <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(string name, IReadOnlyList<Regex> expressions, out ReadOnlySpan<char> newName)
+ 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++)
{
@@ -33,12 +40,6 @@ namespace Emby.Naming.Video
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);
int index = match.Index;
if (match.Success && index != 0)