diff options
| author | David <daullmer@gmail.com> | 2020-06-07 15:41:49 +0200 |
|---|---|---|
| committer | David <daullmer@gmail.com> | 2020-06-07 15:41:49 +0200 |
| commit | 7fa374f8a2560cd1c58584b3d5b0567c91ef4138 (patch) | |
| tree | b96dadbda3c644d05d9e65d36bbc1b28d9b11f90 /Jellyfin.Api/Helpers/RequestHelpers.cs | |
| parent | f3029428cd118b34d73706fdd85cc3918b312a86 (diff) | |
Move Split method from BaseJellyfinApiController.cs to RequestHelpers.cs
Diffstat (limited to 'Jellyfin.Api/Helpers/RequestHelpers.cs')
| -rw-r--r-- | Jellyfin.Api/Helpers/RequestHelpers.cs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/Jellyfin.Api/Helpers/RequestHelpers.cs b/Jellyfin.Api/Helpers/RequestHelpers.cs new file mode 100644 index 000000000..6c661e2d3 --- /dev/null +++ b/Jellyfin.Api/Helpers/RequestHelpers.cs @@ -0,0 +1,29 @@ +using System; + +namespace Jellyfin.Api.Helpers +{ + /// <summary> + /// Request Extensions. + /// </summary> + public static class RequestHelpers + { + /// <summary> + /// Splits a string at a seperating character into an array of substrings. + /// </summary> + /// <param name="value">The string to split.</param> + /// <param name="separator">The char that seperates 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); + } + } +} |
