handle common 'v' version prefix on GitHub (#336)

This commit is contained in:
Jesse Plamondon-Willard 2017-09-24 02:15:28 -04:00
parent 00957a2317
commit 5f85d89974
1 changed files with 9 additions and 1 deletions

View File

@ -55,11 +55,19 @@ namespace StardewModdingAPI.Web.Framework.ModRepositories
{ {
try try
{ {
// fetch data
GitRelease release = await this.Client GitRelease release = await this.Client
.GetAsync(string.Format(this.ReleaseUrlFormat, id)) .GetAsync(string.Format(this.ReleaseUrlFormat, id))
.As<GitRelease>(); .As<GitRelease>();
return new ModInfoModel(id, release.Tag, $"https://github.com/{id}/releases"); // extract fields
string name = id;
string version = release.Tag;
if (version.StartsWith("v")) // common format on GitHub
version = version.Substring(1);
string url = $"https://github.com/{id}/releases";
return new ModInfoModel(name, version, url);
} }
catch (Exception ex) catch (Exception ex)
{ {