Skip to content

Commit

Permalink
Fix app cast gen not working w/multiple dashes
Browse files Browse the repository at this point in the history
Closes #623
  • Loading branch information
Deadpikle committed Oct 5, 2024
1 parent 2b4faa5 commit e128349
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/NetSparkle.Tests.AppCastGenerator/AppCastMakerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ public void CanGetVersionFromName()
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("appsetup_2.10.1.exe"));
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("appsetup 2.10.1.exe"));
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("appsetup2.10.1.exe"));

// #623
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("app-setup-2.10.1.exe"));
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("my-app-setup-2.10.1.exe"));
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("my-app-setup-2.10.1.exe"));
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("my-app-setup 2.10.1.exe"));
Assert.Equal("2.1", AppCastMaker.GetVersionFromName("my--app-setup-2.1.exe"));
Assert.Equal("2.10.1", AppCastMaker.GetVersionFromName("-my--app-setup-2.10.1.exe"));

// Invalid semantic versions tests
Assert.Null(AppCastMaker.GetVersionFromName("app 1.2.3-0123.txt"));
Expand Down
6 changes: 3 additions & 3 deletions src/NetSparkle.Tools.AppCastGenerator/AppCastMaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ private static string RemoveTextBlockFromRight(string input)
// if segment has text in it at the start and digits later, get rid of text and +/- symbol
if (Regex.IsMatch(segment, @"[a-zA-Z]") && Regex.IsMatch(segment, @"\d"))
{
var match = Regex.Match(segment, @"[^+-]*[a-zA-Z][+-]?");
if (match.Success)
var match = Regex.Matches(segment, @"[^+-]*[a-zA-Z][+-]?");
if (match.Count > 0)
{
segment = segment.Substring(match.Index + match.Length);
segment = segment.Substring(match.Last().Index + match.Last().Length);
lastVersionToCheck = true;
}
}
Expand Down

0 comments on commit e128349

Please sign in to comment.