RequestHelpers.cs 992 B

1234567891011121314151617181920212223242526272829
  1. using System;
  2. namespace Jellyfin.Api.Helpers
  3. {
  4. /// <summary>
  5. /// Request Extensions.
  6. /// </summary>
  7. public static class RequestHelpers
  8. {
  9. /// <summary>
  10. /// Splits a string at a separating character into an array of substrings.
  11. /// </summary>
  12. /// <param name="value">The string to split.</param>
  13. /// <param name="separator">The char that separates the substrings.</param>
  14. /// <param name="removeEmpty">Option to remove empty substrings from the array.</param>
  15. /// <returns>An array of the substrings.</returns>
  16. internal static string[] Split(string value, char separator, bool removeEmpty)
  17. {
  18. if (string.IsNullOrWhiteSpace(value))
  19. {
  20. return Array.Empty<string>();
  21. }
  22. return removeEmpty
  23. ? value.Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries)
  24. : value.Split(separator);
  25. }
  26. }
  27. }