illegal filenames

This commit is contained in:
glax 2023-05-25 16:55:58 +02:00
parent afa18d6a2c
commit 147a20385b

View File

@ -1,4 +1,5 @@
using System.Globalization;
using System.Text.RegularExpressions;
namespace Tranga;
@ -14,14 +15,15 @@ public struct Chapter
public string url { get; }
public string fileName { get; }
public string sortNumber { get; }
private static readonly Regex LegalCharacters = new Regex(@"([A-z]*[0-9]* *\.*-*,*\]*\[*'*~*!*)*");
public Chapter(string? name, string? volumeNumber, string? chapterNumber, string url)
{
this.name = name;
this.volumeNumber = volumeNumber is { Length: > 0 } ? volumeNumber : "1";
this.chapterNumber = chapterNumber;
this.url = url;
string chapterName = string.Concat((name ?? "").Split(Path.GetInvalidFileNameChars()));
string chapterName = string.Concat(LegalCharacters.Matches(name ?? ""));
NumberFormatInfo nfi = new NumberFormatInfo()
{
NumberDecimalSeparator = "."