diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-06-06 00:33:13 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-06-06 00:33:13 -0400 |
commit | 18906de0f4a31b70f21f386f65bd3fda3ec9fb13 (patch) | |
tree | 7dce66195ea93bd7a28ab2f7e16cd774644c2a80 /src/SMAPI.Web/Framework | |
parent | 53a6833ab22fb41e909ed8ef50aa9262735818d9 (diff) | |
download | SMAPI-18906de0f4a31b70f21f386f65bd3fda3ec9fb13.tar.gz SMAPI-18906de0f4a31b70f21f386f65bd3fda3ec9fb13.tar.bz2 SMAPI-18906de0f4a31b70f21f386f65bd3fda3ec9fb13.zip |
only return optional Nexus version if newer (#532)
Diffstat (limited to 'src/SMAPI.Web/Framework')
-rw-r--r-- | src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs b/src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs index df5a437d..1b3fa195 100644 --- a/src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs +++ b/src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs @@ -83,6 +83,7 @@ namespace StardewModdingAPI.Web.Framework.Clients.Nexus string url = this.GetModUrl(id); string name = doc.DocumentNode.SelectSingleNode("//h1")?.InnerText.Trim(); string version = doc.DocumentNode.SelectSingleNode("//ul[contains(@class, 'stats')]//li[@class='stat-version']//div[@class='stat']")?.InnerText.Trim(); + SemanticVersion.TryParse(version, out ISemanticVersion parsedVersion); // extract file versions List<string> rawVersions = new List<string>(); @@ -105,16 +106,19 @@ namespace StardewModdingAPI.Web.Framework.Clients.Nexus { if (!SemanticVersion.TryParse(rawVersion, out ISemanticVersion cur)) continue; + if (parsedVersion != null && !cur.IsNewerThan(parsedVersion)) + continue; + if (latestFileVersion != null && !cur.IsNewerThan(latestFileVersion)) + continue; - if (latestFileVersion == null || cur.IsNewerThan(latestFileVersion)) - latestFileVersion = cur; + latestFileVersion = cur; } // yield info return new NexusMod { Name = name, - Version = version, + Version = parsedVersion?.ToString() ?? version, LatestFileVersion = latestFileVersion, Url = url }; |