aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Helpers/RequestHelpers.cs
diff options
context:
space:
mode:
authorcrobibero <cody@robibe.ro>2020-06-13 15:20:13 -0600
committercrobibero <cody@robibe.ro>2020-06-13 15:20:13 -0600
commitbcce8190ffe6cf2b4926c64bca98b8266c0937b0 (patch)
tree7008786b1e0631445437f451cc6422b4be9a5f0d /Jellyfin.Api/Helpers/RequestHelpers.cs
parent88b6c26472ad57822d3ab79a043db259ffcbb0e3 (diff)
parent0011e8df47380936742302ef40639a4626a780ed (diff)
Merge remote-tracking branch 'upstream/api-migration' into api-channel
Diffstat (limited to 'Jellyfin.Api/Helpers/RequestHelpers.cs')
-rw-r--r--Jellyfin.Api/Helpers/RequestHelpers.cs23
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);
+ }
}
}