The Free Software Media System - Server Backend & API
Move Split method from BaseJellyfinApiController.cs to RequestHelpers.cs
David7fa374f8a256
diff --git a/Jellyfin.Api/BaseJellyfinApiController.cs b/Jellyfin.Api/BaseJellyfinApiController.csindex 6a9e48f8dd..22b9c3fd67 100644--- a/Jellyfin.Api/BaseJellyfinApiController.cs+++ b/Jellyfin.Api/BaseJellyfinApiController.cs@@ -10,23 +10,5 @@ namespace Jellyfin.Api[Route("[controller]")]public class BaseJellyfinApiController : ControllerBase{- /// <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);- }}}diff --git a/Jellyfin.Api/Controllers/SearchController.cs b/Jellyfin.Api/Controllers/SearchController.csindex 2ee3ef25b3..b6178e121d 100644--- a/Jellyfin.Api/Controllers/SearchController.cs+++ b/Jellyfin.Api/Controllers/SearchController.cs@@ -3,6 +3,7 @@ using System.ComponentModel;using System.ComponentModel.DataAnnotations;using System.Globalization;using System.Linq;+using Jellyfin.Api.Helpers;using MediaBrowser.Controller.Drawing;using MediaBrowser.Controller.Dto;using MediaBrowser.Controller.Entities;@@ -105,9 +106,9 @@ namespace Jellyfin.Api.ControllersIncludeStudios = includeStudios,StartIndex = startIndex,UserId = userId,- IncludeItemTypes = Split(includeItemTypes, ',', true),- ExcludeItemTypes = Split(excludeItemTypes, ',', true),- MediaTypes = Split(mediaTypes, ',', true),+ IncludeItemTypes = RequestHelpers.Split(includeItemTypes, ',', true),+ ExcludeItemTypes = RequestHelpers.Split(excludeItemTypes, ',', true),+ MediaTypes = RequestHelpers.Split(mediaTypes, ',', true),ParentId = parentId,IsKids = isKids,diff --git a/Jellyfin.Api/Helpers/RequestHelpers.cs b/Jellyfin.Api/Helpers/RequestHelpers.csnew file mode 100644index 0000000000..6c661e2d32--- /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);+ }+ }+}