Fix tag checks

This commit is contained in:
Shadowghost
2026-01-31 23:44:07 +01:00
parent 2789532aa8
commit 09a729effe
5 changed files with 81 additions and 52 deletions

View File

@@ -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;
}
}
}