mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
21 lines
753 B
C#
21 lines
753 B
C#
using System.Text.RegularExpressions;
|
|
|
|
namespace Velopack.Tests.OldSquirrel;
|
|
|
|
public static class VersionExtensions
|
|
{
|
|
static readonly Regex _suffixRegex = new Regex(@"(-full|-delta)?\.nupkg$", RegexOptions.Compiled);
|
|
static readonly Regex _versionRegex = new Regex(@"\d+(\.\d+){0,3}(-[A-Za-z][0-9A-Za-z-]*)?$", RegexOptions.Compiled);
|
|
|
|
//public static SemanticVersion ToSemanticVersion(this IReleasePackage package)
|
|
//{
|
|
// return package.InputPackageFile.ToSemanticVersion();
|
|
//}
|
|
|
|
public static SemanticVersion ToSemanticVersion(this string fileName)
|
|
{
|
|
var name = _suffixRegex.Replace(fileName, "");
|
|
var version = _versionRegex.Match(name).Value;
|
|
return new SemanticVersion(version);
|
|
}
|
|
} |