mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Changed to use span
This commit is contained in:
parent
7185de970c
commit
bd71de131c
@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
|
using MediaBrowser.Common.Extensions;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Http.Features;
|
using Microsoft.AspNetCore.Http.Features;
|
||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
@ -61,19 +62,23 @@ namespace Jellyfin.Server.Middleware
|
|||||||
}
|
}
|
||||||
|
|
||||||
var pairs = new Dictionary<string, StringValues>();
|
var pairs = new Dictionary<string, StringValues>();
|
||||||
var queryString = unencodedKey.Split('&', System.StringSplitOptions.RemoveEmptyEntries);
|
var queryString = unencodedKey.SpanSplit('&');
|
||||||
|
|
||||||
foreach (var pair in queryString)
|
foreach (var pair in queryString)
|
||||||
{
|
{
|
||||||
var item = pair.Split('=', System.StringSplitOptions.RemoveEmptyEntries);
|
var item = pair.Split('=');
|
||||||
if (item.Length > 0)
|
item.MoveNext();
|
||||||
|
|
||||||
|
var key = item.Current;
|
||||||
|
var val = item.MoveNext() ? item.Current : string.Empty;
|
||||||
|
if (key.Length == 0 && val.Length == 0)
|
||||||
{
|
{
|
||||||
pairs.Add(item[0], new StringValues(item.Length == 2 ? item[1] : string.Empty));
|
// encoded is an equals.
|
||||||
}
|
pairs.Add(pair.ToString(), new StringValues(string.Empty));
|
||||||
else
|
continue;
|
||||||
{
|
|
||||||
pairs.Add(pair, string.Empty);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pairs.Add(key.ToString(), new StringValues(val.ToString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
_store = new QueryCollection(pairs);
|
_store = new QueryCollection(pairs);
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="../../Jellyfin.Api/Jellyfin.Api.csproj" />
|
<ProjectReference Include="../../Jellyfin.Api/Jellyfin.Api.csproj" />
|
||||||
<ProjectReference Include="../../Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj" />
|
<ProjectReference Include="../../Jellyfin.Server.Implementations/Jellyfin.Server.Implementations.csproj" />
|
||||||
|
<ProjectReference Include="..\Jellyfin.Server.Integration.Tests\Jellyfin.Server.Integration.Tests.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Emby.Server.Implementations\Emby.Server.Implementations.csproj" />
|
<ProjectReference Include="..\..\Emby.Server.Implementations\Emby.Server.Implementations.csproj" />
|
||||||
<ProjectReference Include="..\..\Jellyfin.Server.Implementations\Jellyfin.Server.Implementations.csproj" />
|
<ProjectReference Include="..\..\Jellyfin.Server.Implementations\Jellyfin.Server.Implementations.csproj" />
|
||||||
|
<ProjectReference Include="..\Jellyfin.Server.Integration.Tests\Jellyfin.Server.Integration.Tests.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -5,9 +5,10 @@ using System.Net;
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Jellyfin.Server.Integration.Tests;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Jellyfin.Api.Tests.Controllers
|
namespace Jellyfin.Server.Implementations.Tests.Middleware
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Defines the test for encoded querystrings in the url.
|
/// Defines the test for encoded querystrings in the url.
|
Loading…
x
Reference in New Issue
Block a user