add workaround for CurseForge prerelease version auto-sync issue

This commit is contained in:
Jesse Plamondon-Willard
2024-08-19 22:17:21 -04:00
parent d28ef2b750
commit 2f0db74ca7
2 changed files with 20 additions and 3 deletions
+1
View File
@@ -34,6 +34,7 @@
* For the update check server:
* Rewrote update checks for mods on CurseForge and ModDrop to use new export API endpoints.
_This should result in much faster update checks for those sites, and less chance of update-check errors when their servers are under heavy load._
* Added workaround for CurseForge auto-syncing prerelease versions with an invalid version number.
* For the log parser:
* Clicking a checkbox in the mod list now always only changes that checkbox, to allow hiding a single mod.
@@ -181,13 +181,29 @@ namespace StardewModdingAPI.Web.Framework.Clients.CurseForge
/// <param name="fileName">The file's internal name.</param>
private string? GetRawVersion(string? displayName, string? fileName)
{
// get raw version
Match match = this.VersionInNamePattern.Match(displayName ?? "");
if (!match.Success)
match = this.VersionInNamePattern.Match(fileName ?? "");
if (!match.Success)
return null;
return match.Success
? match.Groups[1].Value
: null;
// fix auto-synced prerelease versions having a double version in the name (like "2.4.0-alpha.20240818-2-4-0-alpha-20240818")
string version = match.Groups[1].Value;
if (version.Length > 2 && version.Length % 2 == 1)
{
int splitIndex = version.Length / 2;
if (version[splitIndex] == '-')
{
string left = version[..splitIndex];
string right = version[(splitIndex + 1)..];
if (left.Replace('.', '-') == right)
version = left;
}
}
return version;
}
/// <summary>Get the full mod page URL for a given ID.</summary>