aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShadowghost <Ghost_of_Stone@web.de>2026-01-31 23:44:07 +0100
committerShadowghost <Ghost_of_Stone@web.de>2026-01-31 23:45:38 +0100
commit09a729effe1c0eeccd3bbc7482923b4d1cdabfc1 (patch)
tree6e4cece5eac29c5e0252724fff2d868786177a78 /src
parent2789532aa88ccc899ff8497537642e1d78b31ef5 (diff)
Fix tag checks
Diffstat (limited to 'src')
-rw-r--r--src/Jellyfin.Extensions/StringExtensions.cs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/Jellyfin.Extensions/StringExtensions.cs b/src/Jellyfin.Extensions/StringExtensions.cs
index 60df47113a..01225cf283 100644
--- a/src/Jellyfin.Extensions/StringExtensions.cs
+++ b/src/Jellyfin.Extensions/StringExtensions.cs
@@ -148,5 +148,30 @@ namespace Jellyfin.Extensions
{
return string.IsNullOrEmpty(text) ? text : text.AsSpan().LeftPart('\0').ToString();
}
+
+ /// <summary>
+ /// Normalizes a string for comparison by removing diacritics, converting to lowercase,
+ /// replacing punctuation/special characters with spaces, and collapsing whitespace.
+ /// </summary>
+ /// <param name="value">The string to normalize.</param>
+ /// <returns>The normalized string, or the original if null/whitespace.</returns>
+ public static string GetCleanValue(this string value)
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ return value;
+ }
+
+ // Remove diacritics and convert to lowercase
+ var cleaned = value.RemoveDiacritics().ToLowerInvariant();
+
+ // Replace all punctuation and special characters with spaces
+ cleaned = Regex.Replace(cleaned, @"[^\p{L}\p{N}\s]", " ");
+
+ // Collapse multiple spaces into single space and trim
+ cleaned = Regex.Replace(cleaned, @"\s+", " ").Trim();
+
+ return cleaned;
+ }
}
}