diff options
| author | Bond_009 <bond.009@outlook.com> | 2020-04-19 15:18:28 +0200 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2020-04-20 10:18:12 +0200 |
| commit | 7f4a229cd2fee89fdd8329c9c9f907e381d45c46 (patch) | |
| tree | ce60fe469b635c7c3369964d9783affebc483639 /Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs | |
| parent | 3142c9b9901cc653eb758ba7d47edbbe2190f83d (diff) | |
Add some simple tests
Diffstat (limited to 'Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs')
| -rw-r--r-- | Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs index 1781df8b5..9c638f439 100644 --- a/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs +++ b/Emby.Server.Implementations/SocketSharp/WebSocketSharpRequest.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Net; using System.Net.Mime; +using MediaBrowser.Common.Extensions; using MediaBrowser.Common.Net; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Extensions; @@ -216,14 +217,14 @@ namespace Emby.Server.Implementations.SocketSharp pi = pi.Slice(1); } - format = LeftPart(pi, '/'); + format = pi.LeftPart('/'); if (format.Length > FormatMaxLength) { return null; } } - format = LeftPart(format, '.'); + format = format.LeftPart('.'); if (format.Contains("json", StringComparison.OrdinalIgnoreCase)) { return "application/json"; @@ -235,16 +236,5 @@ namespace Emby.Server.Implementations.SocketSharp return null; } - - public static ReadOnlySpan<char> LeftPart(ReadOnlySpan<char> strVal, char needle) - { - if (strVal == null) - { - return null; - } - - var pos = strVal.IndexOf(needle); - return pos == -1 ? strVal : strVal.Slice(0, pos); - } } } |
