diff options
| author | Shadowghost <Ghost_of_Stone@web.de> | 2026-01-31 23:44:07 +0100 |
|---|---|---|
| committer | Shadowghost <Ghost_of_Stone@web.de> | 2026-01-31 23:45:38 +0100 |
| commit | 09a729effe1c0eeccd3bbc7482923b4d1cdabfc1 (patch) | |
| tree | 6e4cece5eac29c5e0252724fff2d868786177a78 /src | |
| parent | 2789532aa88ccc899ff8497537642e1d78b31ef5 (diff) | |
Fix tag checks
Diffstat (limited to 'src')
| -rw-r--r-- | src/Jellyfin.Extensions/StringExtensions.cs | 25 |
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; + } } } |
