diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-02-20 21:32:55 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-02-20 21:32:55 -0500 |
commit | dd27b3bf35d01e4fd0703e47d538bd8cec03652b (patch) | |
tree | 3f3b00c4c1b9cb5fafcfc975e8de7e999b1dc36b /src/SMAPI.Web/Controllers/ModsApiController.cs | |
parent | 6a9bf10a81f4557d44668666117d99440d99d873 (diff) | |
download | SMAPI-dd27b3bf35d01e4fd0703e47d538bd8cec03652b.tar.gz SMAPI-dd27b3bf35d01e4fd0703e47d538bd8cec03652b.tar.bz2 SMAPI-dd27b3bf35d01e4fd0703e47d538bd8cec03652b.zip |
fix parsing four-part versions from the update-check API
Diffstat (limited to 'src/SMAPI.Web/Controllers/ModsApiController.cs')
-rw-r--r-- | src/SMAPI.Web/Controllers/ModsApiController.cs | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/src/SMAPI.Web/Controllers/ModsApiController.cs b/src/SMAPI.Web/Controllers/ModsApiController.cs index 8370fe09..06768f03 100644 --- a/src/SMAPI.Web/Controllers/ModsApiController.cs +++ b/src/SMAPI.Web/Controllers/ModsApiController.cs @@ -296,7 +296,7 @@ namespace StardewModdingAPI.Web.Controllers { if (result.Version == null) result.SetError(RemoteModStatus.InvalidData, $"The update key '{updateKey}' matches a mod with no version number."); - else if (!this.TryParseVersion(result.Version, allowNonStandardVersions, out _)) + else if (!SemanticVersion.TryParse(result.Version, allowNonStandardVersions, out _)) result.SetError(RemoteModStatus.InvalidData, $"The update key '{updateKey}' matches a mod with invalid semantic version '{result.Version}'."); } @@ -360,11 +360,11 @@ namespace StardewModdingAPI.Web.Controllers { // try mapped version string rawNewVersion = this.GetRawMappedVersion(version, map, allowNonStandard); - if (this.TryParseVersion(rawNewVersion, allowNonStandard, out ISemanticVersion parsedNew)) + if (SemanticVersion.TryParse(rawNewVersion, allowNonStandard, out ISemanticVersion parsedNew)) return parsedNew; // return original version - return this.TryParseVersion(version, allowNonStandard, out ISemanticVersion parsedOld) + return SemanticVersion.TryParse(version, allowNonStandard, out ISemanticVersion parsedOld) ? parsedOld : null; } @@ -383,31 +383,19 @@ namespace StardewModdingAPI.Web.Controllers return map[version]; // match parsed version - if (this.TryParseVersion(version, allowNonStandard, out ISemanticVersion parsed)) + if (SemanticVersion.TryParse(version, allowNonStandard, out ISemanticVersion parsed)) { if (map.ContainsKey(parsed.ToString())) return map[parsed.ToString()]; foreach (var pair in map) { - if (this.TryParseVersion(pair.Key, allowNonStandard, out ISemanticVersion target) && parsed.Equals(target) && this.TryParseVersion(pair.Value, allowNonStandard, out ISemanticVersion newVersion)) + if (SemanticVersion.TryParse(pair.Key, allowNonStandard, out ISemanticVersion target) && parsed.Equals(target) && SemanticVersion.TryParse(pair.Value, allowNonStandard, out ISemanticVersion newVersion)) return newVersion.ToString(); } } return version; } - - /// <summary>Try to parse a version string.</summary> - /// <param name="version">The version string.</param> - /// <param name="allowNonStandard">Whether to allow non-standard versions.</param> - /// <param name="parsed">The parsed representation.</param> - /// <returns>Returns whether parsing the version succeeded.</returns> - public bool TryParseVersion(string version, bool allowNonStandard, out ISemanticVersion parsed) - { - return allowNonStandard - ? SemanticVersion.TryParseNonStandard(version, out parsed) - : SemanticVersion.TryParse(version, out parsed); - } } } |