mirror of
https://github.com/dnwSilver/tld.git
synced 2025-01-19 09:22:08 +00:00
🐛 Fix bug when js version start with 'v'.
This commit is contained in:
parent
dd339130b8
commit
220c33ed97
@ -40,9 +40,14 @@ public static class Extensions
|
|||||||
return stringInfo.LengthInTextElements;
|
return stringInfo.LengthInTextElements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string RemoveVersionPrefix(this string version)
|
||||||
|
{
|
||||||
|
return version.Replace("^", "").Replace("v", "").Replace("~", "");
|
||||||
|
}
|
||||||
|
|
||||||
public static Version ToVersion(this string textVersion)
|
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 major = Convert.ToInt32(version[0]);
|
||||||
var minor = Convert.ToInt32(version[1]);
|
var minor = Convert.ToInt32(version[1]);
|
||||||
var patch = Convert.ToInt32(version[2].Split('-')[0]);
|
var patch = Convert.ToInt32(version[2].Split('-')[0]);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using TUI.Controls.Components;
|
using TUI.Controls.Components;
|
||||||
|
using TUI.Engine;
|
||||||
|
|
||||||
namespace TUI.Domain;
|
namespace TUI.Domain;
|
||||||
|
|
||||||
@ -8,17 +9,17 @@ public class Version
|
|||||||
public readonly int Minor;
|
public readonly int Minor;
|
||||||
public readonly int Patch;
|
public readonly int Patch;
|
||||||
public readonly VersionType Type;
|
public readonly VersionType Type;
|
||||||
|
|
||||||
public Version(string version)
|
public Version(string version)
|
||||||
{
|
{
|
||||||
var parts = version.Split('.');
|
var parts = version.Split('.');
|
||||||
|
|
||||||
Major = Convert.ToInt32(parts[0].Replace("^", "").Replace("~", ""));
|
Major = Convert.ToInt32(parts[0].RemoveVersionPrefix());
|
||||||
Minor = Convert.ToInt32(parts[1]);
|
Minor = Convert.ToInt32(parts[1]);
|
||||||
Patch = Convert.ToInt32(string.Join("", parts[2].TakeWhile(char.IsDigit)));
|
Patch = Convert.ToInt32(string.Join("", parts[2].TakeWhile(char.IsDigit)));
|
||||||
|
|
||||||
var extension = parts[2].Replace(Patch.ToString(), "");
|
var extension = parts[2].Replace(Patch.ToString(), "");
|
||||||
|
|
||||||
Type = extension switch
|
Type = extension switch
|
||||||
{
|
{
|
||||||
not null when extension.Contains("rc") => VersionType.Candidate,
|
not null when extension.Contains("rc") => VersionType.Candidate,
|
||||||
|
Loading…
Reference in New Issue
Block a user