🐛 Fix bug when js version start with 'v'.

This commit is contained in:
Kolosov Alexandr 2024-12-06 19:41:10 +05:00
parent dd339130b8
commit 220c33ed97
2 changed files with 12 additions and 6 deletions

View File

@ -40,9 +40,14 @@ public static class Extensions
return stringInfo.LengthInTextElements;
}
public static string RemoveVersionPrefix(this string version)
{
return version.Replace("^", "").Replace("v", "").Replace("~", "");
}
public static Version ToVersion(this string textVersion)
{
var version = textVersion.Replace("^", "").Replace("v", "").Replace("~", "").Split(".");
var version = textVersion.RemoveVersionPrefix().Split(".");
var major = Convert.ToInt32(version[0]);
var minor = Convert.ToInt32(version[1]);
var patch = Convert.ToInt32(version[2].Split('-')[0]);

View File

@ -1,4 +1,5 @@
using TUI.Controls.Components;
using TUI.Engine;
namespace TUI.Domain;
@ -13,7 +14,7 @@ public class Version
{
var parts = version.Split('.');
Major = Convert.ToInt32(parts[0].Replace("^", "").Replace("~", ""));
Major = Convert.ToInt32(parts[0].RemoveVersionPrefix());
Minor = Convert.ToInt32(parts[1]);
Patch = Convert.ToInt32(string.Join("", parts[2].TakeWhile(char.IsDigit)));