mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-05-03 23:36:38 +01:00
Fix tag checks
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user