diff options
| author | gnattu <gnattu@users.noreply.github.com> | 2025-05-19 08:40:18 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-18 18:40:18 -0600 |
| commit | 9d601f8e9bed64927ac5cdad5ecac9730d55c435 (patch) | |
| tree | bdb2a91ff08468d6688eadf9d706cd55bd2cba7a /src | |
| parent | fe2596dc0e389c0496a384cc1893fddd4742ed37 (diff) | |
Terminate at null char for audio tags (#14100)
Diffstat (limited to 'src')
| -rw-r--r-- | src/Jellyfin.Extensions/StringExtensions.cs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/Jellyfin.Extensions/StringExtensions.cs b/src/Jellyfin.Extensions/StringExtensions.cs index 715cbf220..60df47113 100644 --- a/src/Jellyfin.Extensions/StringExtensions.cs +++ b/src/Jellyfin.Extensions/StringExtensions.cs @@ -135,5 +135,18 @@ namespace Jellyfin.Extensions { return values.Select(i => (i ?? string.Empty).Trim()); } + + /// <summary> + /// Truncates a string at the first null character ('\0'). + /// </summary> + /// <param name="text">The input string.</param> + /// <returns> + /// The substring up to (but not including) the first null character, + /// or the original string if no null character is present. + /// </returns> + public static string TruncateAtNull(this string text) + { + return string.IsNullOrEmpty(text) ? text : text.AsSpan().LeftPart('\0').ToString(); + } } } |
