mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-01 09:48:37 +00:00
Fix Qodana warnings
This commit is contained in:
parent
e6c75d2b86
commit
f681ef3ba7
2 changed files with 10 additions and 10 deletions
|
@ -3,21 +3,22 @@ using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
|
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
|
||||||
|
|
||||||
public static class PatchworkHelper
|
public static partial class PatchworkHelper
|
||||||
{
|
{
|
||||||
static int requiredMajor = ServerConfiguration.Instance.Authentication.PatchworkMajorVersionMinimum;
|
static readonly int requiredMajor = ServerConfiguration.Instance.Authentication.PatchworkMajorVersionMinimum;
|
||||||
static int requiredMinor = ServerConfiguration.Instance.Authentication.PatchworkMinorVersionMinimum;
|
static readonly int requiredMinor = ServerConfiguration.Instance.Authentication.PatchworkMinorVersionMinimum;
|
||||||
|
|
||||||
|
[GeneratedRegex(@"^PatchworkLBP[123V] (\d{1,5})\.(\d{1,5})$")]
|
||||||
|
private static partial Regex PatchworkUserAgentRegex();
|
||||||
|
|
||||||
public static bool IsValidPatchworkUserAgent(string userAgent)
|
public static bool IsValidPatchworkUserAgent(string userAgent)
|
||||||
{
|
{
|
||||||
Match result = Regex.Match(userAgent, @"^PatchworkLBP[123V] (\d{1,5})\.(\d{1,5})$");
|
Match result = PatchworkUserAgentRegex().Match(userAgent);
|
||||||
if (!result.Success) return false;
|
if (!result.Success) return false;
|
||||||
|
|
||||||
if (!int.TryParse(result.Groups[1].Value, out int major) || !int.TryParse(result.Groups[2].Value, out int minor))
|
if (!int.TryParse(result.Groups[1].Value, out int major) || !int.TryParse(result.Groups[2].Value, out int minor))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (major < requiredMajor || minor < requiredMinor)
|
return major >= requiredMajor && minor >= requiredMinor;
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,8 +1,7 @@
|
||||||
using System;
|
|
||||||
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
|
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace ProjectLighthouse.Tests.GameApiTests.Unit.Helpers;
|
namespace ProjectLighthouse.Tests.GameApiTests.Unit;
|
||||||
|
|
||||||
[Trait("Category", "Unit")]
|
[Trait("Category", "Unit")]
|
||||||
public class PatchworkUserAgentTests
|
public class PatchworkUserAgentTests
|
Loading…
Add table
Add a link
Reference in a new issue