using System; using MediaBrowser.Controller.Net; using MediaBrowser.Controller.Session; namespace Jellyfin.Api.Helpers { /// /// Request Extensions. /// public static class RequestHelpers { /// /// Splits a string at a separating character into an array of substrings. /// /// The string to split. /// The char that separates the substrings. /// Option to remove empty substrings from the array. /// An array of the substrings. internal static string[] Split(string value, char separator, bool removeEmpty) { if (string.IsNullOrWhiteSpace(value)) { return Array.Empty(); } return removeEmpty ? value.Split(new[] { separator }, StringSplitOptions.RemoveEmptyEntries) : value.Split(separator); } internal static SessionInfo GetSession(ISessionContext sessionContext) { // TODO: how do we get a SessionInfo without IRequest? SessionInfo session = sessionContext.GetSession("Request"); if (session == null) { throw new ArgumentException("Session not found."); } return session; } } }