Add some simple tests

This commit is contained in:
Bond_009
2020-04-19 15:18:28 +02:00
parent 3142c9b990
commit 7f4a229cd2
20 changed files with 155 additions and 60 deletions

View File

@@ -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);
}
}
}