makes logreplace command automatically add lowercap versions of from-string

This commit is contained in:
Ben 2025-04-17 15:29:40 +02:00
parent cd17b0c887
commit 16b5ee4fd1
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B

View File

@ -28,14 +28,14 @@ namespace BiblioTech.Rewards
public void Add(string from, string to)
{
if (replacements.ContainsKey(from))
AddOrUpdate(from, to);
var lower = from.ToLowerInvariant();
if (lower != from)
{
replacements[from] = to;
}
else
{
replacements.Add(from, to);
AddOrUpdate(lower, to);
}
Save();
}
@ -55,6 +55,18 @@ namespace BiblioTech.Rewards
return result;
}
private void AddOrUpdate(string from, string to)
{
if (replacements.ContainsKey(from))
{
replacements[from] = to;
}
else
{
replacements.Add(from, to);
}
}
private void Save()
{
ReplaceJson[] replaces = replacements.Select(pair =>