Add first test

This commit is contained in:
cvium
2021-09-25 11:17:16 +02:00
parent fa38b741ce
commit c7b25a9fe4
5 changed files with 79 additions and 8 deletions

View File

@@ -2,14 +2,9 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="../../SharedVersion.cs" />
</ItemGroup>
<!-- Code Analyzers-->
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<PackageReference Include="SerilogAnalyzer" Version="0.15.0" PrivateAssets="All" />
@@ -22,9 +17,15 @@
<ProjectReference Include="../../MediaBrowser.Controller/MediaBrowser.Controller.csproj" />
<ProjectReference Include="../Jellyfin.MediaEncoding.Keyframes/Jellyfin.MediaEncoding.Keyframes.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Jellyfin.MediaEncoding.Hls.Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
</Project>

View File

@@ -176,12 +176,18 @@ namespace Jellyfin.MediaEncoding.Hls.Playlist
internal static bool IsExtractionAllowedForFile(ReadOnlySpan<char> filePath, string[] allowedExtensions)
{
var extension = Path.GetExtension(filePath);
if (extension.IsEmpty)
{
return false;
}
// Remove the leading dot
var extension = Path.GetExtension(filePath)[1..];
var extensionWithoutDot = extension[1..];
for (var i = 0; i < allowedExtensions.Length; i++)
{
var allowedExtension = allowedExtensions[i];
if (extension.Equals(allowedExtension, StringComparison.OrdinalIgnoreCase))
if (extensionWithoutDot.Equals(allowedExtension, StringComparison.OrdinalIgnoreCase))
{
return true;
}