Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.
C# annotationscbzcomicinfocomicscomics-readercross-platformcsharpepubepub-readerfreelinuxmangamedia-servermetadataopdsopds-feedpdfself-hostedubooquitywindows
Fixed a bug in IsImage and IsArchive where I was using a contains instead of matching the regex.
Joseph Milazzoe9dfc1bda050
diff --git a/API.Tests/Services/CacheServiceTests.cs b/API.Tests/Services/CacheServiceTests.csindex 4e10cf836..80ee0438e 100644--- a/API.Tests/Services/CacheServiceTests.cs+++ b/API.Tests/Services/CacheServiceTests.cs@@ -8,15 +8,15 @@ namespace API.Tests.Services{public class CacheServiceTests{- private readonly CacheService _cacheService;- private readonly ILogger<CacheService> _logger = Substitute.For<ILogger<CacheService>>();- private readonly IUnitOfWork _unitOfWork = Substitute.For<IUnitOfWork>();- private readonly IArchiveService _archiveService = Substitute.For<IArchiveService>();- private readonly IDirectoryService _directoryService = Substitute.For<DirectoryService>();+ // private readonly CacheService _cacheService;+ // private readonly ILogger<CacheService> _logger = Substitute.For<ILogger<CacheService>>();+ // private readonly IUnitOfWork _unitOfWork = Substitute.For<IUnitOfWork>();+ // private readonly IArchiveService _archiveService = Substitute.For<IArchiveService>();+ // private readonly IDirectoryService _directoryService = Substitute.For<DirectoryService>();public CacheServiceTests(){- _cacheService = new CacheService(_logger, _unitOfWork, _archiveService, _directoryService);+ //_cacheService = new CacheService(_logger, _unitOfWork, _archiveService, _directoryService);}//string GetCachedPagePath(Volume volume, int page)diff --git a/API/Parser/Parser.cs b/API/Parser/Parser.csindex 33bf67978..dc59d3b5c 100644--- a/API/Parser/Parser.cs+++ b/API/Parser/Parser.cs@@ -1,6 +1,7 @@using System;using System.IO;using System.Linq;+using System.Reflection;using System.Text.RegularExpressions;using API.Entities;@@ -10,6 +11,8 @@ namespace API.Parser{public static readonly string MangaFileExtensions = @"\.cbz|\.zip"; // |\.rar|\.cbrpublic static readonly string ImageFileExtensions = @"\.png|\.jpeg|\.jpg|\.gif";+ private static readonly Regex ImageRegex = new Regex(ImageFileExtensions, RegexOptions.IgnoreCase | RegexOptions.Compiled);+ private static readonly Regex MangaFileRegex = new Regex(MangaFileExtensions, RegexOptions.IgnoreCase | RegexOptions.Compiled);//?: is a non-capturing group in C#, else anything in () will be a groupprivate static readonly Regex[] MangaVolumeRegex = new[]@@ -388,13 +391,13 @@ namespace API.Parserpublic static bool IsArchive(string filePath){var fileInfo = new FileInfo(filePath);- return MangaFileExtensions.Contains(fileInfo.Extension);+ return MangaFileRegex.IsMatch(fileInfo.Extension);}public static bool IsImage(string filePath){var fileInfo = new FileInfo(filePath);- return ImageFileExtensions.Contains(fileInfo.Extension);+ return ImageRegex.IsMatch(fileInfo.Extension);}public static int MinimumNumberFromRange(string range)