BaseJellyfinApiController.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using Microsoft.AspNetCore.Mvc;
  3. namespace Jellyfin.Api
  4. {
  5. /// <summary>
  6. /// Base api controller for the API setting a default route.
  7. /// </summary>
  8. [ApiController]
  9. [Route("[controller]")]
  10. public class BaseJellyfinApiController : ControllerBase
  11. {
  12. /// <summary>
  13. /// Splits a string at a seperating character into an array of substrings.
  14. /// </summary>
  15. /// <param name="value">The string to split.</param>
  16. /// <param name="separator">The char that seperates the substrings.</param>
  17. /// <param name="removeEmpty">Option to remove empty substrings from the array.</param>
  18. /// <returns>An array of the substrings.</returns>
  19. internal static string[] Split(string value, char separator, bool removeEmpty)
  20. {
  21. if (string.IsNullOrWhiteSpace(value))
  22. {
  23. return Array.Empty<string>();
  24. }
  25. return removeEmpty
  26. ? value.Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries)
  27. : value.Split(separator);
  28. }
  29. }
  30. }