diff options
Diffstat (limited to 'Jellyfin.Api/Helpers/RequestHelpers.cs')
| -rw-r--r-- | Jellyfin.Api/Helpers/RequestHelpers.cs | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/Jellyfin.Api/Helpers/RequestHelpers.cs b/Jellyfin.Api/Helpers/RequestHelpers.cs index e74555f33..1e9aa7b43 100644 --- a/Jellyfin.Api/Helpers/RequestHelpers.cs +++ b/Jellyfin.Api/Helpers/RequestHelpers.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using MediaBrowser.Model.Entities; @@ -71,7 +71,7 @@ namespace Jellyfin.Api.Helpers } return null; - }).Where(i => i.HasValue).Select(i => i.Value).ToArray(); + }).Where(i => i.HasValue).Select(i => i!.Value).ToArray(); } /// <summary> @@ -85,5 +85,24 @@ namespace Jellyfin.Api.Helpers ? Array.Empty<ItemFilter>() : filters.Split(',').Select(v => Enum.Parse<ItemFilter>(v, true)); } + + /// <summary> + /// Splits a string at a separating character into an array of substrings. + /// </summary> + /// <param name="value">The string to split.</param> + /// <param name="separator">The char that separates the substrings.</param> + /// <param name="removeEmpty">Option to remove empty substrings from the array.</param> + /// <returns>An array of the substrings.</returns> + internal static string[] Split(string value, char separator, bool removeEmpty) + { + if (string.IsNullOrWhiteSpace(value)) + { + return Array.Empty<string>(); + } + + return removeEmpty + ? value.Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries) + : value.Split(separator); + } } } |
