aboutsummaryrefslogtreecommitdiff
path: root/src/Jellyfin.Extensions/StringExtensions.cs
diff options
context:
space:
mode:
authorgnattu <gnattu@users.noreply.github.com>2025-05-19 08:40:18 +0800
committerGitHub <noreply@github.com>2025-05-18 18:40:18 -0600
commit9d601f8e9bed64927ac5cdad5ecac9730d55c435 (patch)
treebdb2a91ff08468d6688eadf9d706cd55bd2cba7a /src/Jellyfin.Extensions/StringExtensions.cs
parentfe2596dc0e389c0496a384cc1893fddd4742ed37 (diff)
Terminate at null char for audio tags (#14100)
Diffstat (limited to 'src/Jellyfin.Extensions/StringExtensions.cs')
-rw-r--r--src/Jellyfin.Extensions/StringExtensions.cs13
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();
+ }
}
}