summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Common/SemanticVersionImpl.cs23
-rw-r--r--src/SMAPI.Web/Framework/VersionConstraint.cs3
2 files changed, 11 insertions, 15 deletions
diff --git a/src/SMAPI.Common/SemanticVersionImpl.cs b/src/SMAPI.Common/SemanticVersionImpl.cs
index c257aaaf..e0f68a7e 100644
--- a/src/SMAPI.Common/SemanticVersionImpl.cs
+++ b/src/SMAPI.Common/SemanticVersionImpl.cs
@@ -9,20 +9,6 @@ namespace StardewModdingAPI.Common
internal class SemanticVersionImpl
{
/*********
- ** Properties
- *********/
- /// <summary>A regular expression matching a semantic version string.</summary>
- /// <remarks>
- /// This pattern is derived from the BNF documentation in the <a href="https://github.com/mojombo/semver">semver repo</a>,
- /// with three important deviations intended to support Stardew Valley mod conventions:
- /// - allows short-form "x.y" versions;
- /// - allows hyphens in prerelease tags as synonyms for dots (like "-unofficial-update.3");
- /// - doesn't allow '+build' suffixes.
- /// </remarks>
- private static readonly Regex Regex = new Regex(@"^(?>(?<major>0|[1-9]\d*))\.(?>(?<minor>0|[1-9]\d*))(?>(?:\.(?<patch>0|[1-9]\d*))?)(?:-(?<prerelease>(?>[a-z0-9]+[\-\.]?)+))?$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.ExplicitCapture);
-
-
- /*********
** Accessors
*********/
/// <summary>The major version incremented for major API changes.</summary>
@@ -37,6 +23,15 @@ namespace StardewModdingAPI.Common
/// <summary>An optional prerelease tag.</summary>
public string Tag { get; }
+ /// <summary>A regular expression matching a semantic version string.</summary>
+ /// <remarks>
+ /// This pattern is derived from the BNF documentation in the <a href="https://github.com/mojombo/semver">semver repo</a>,
+ /// with three important deviations intended to support Stardew Valley mod conventions:
+ /// - allows short-form "x.y" versions;
+ /// - allows hyphens in prerelease tags as synonyms for dots (like "-unofficial-update.3");
+ /// - doesn't allow '+build' suffixes.
+ /// </remarks>
+ internal static readonly Regex Regex = new Regex(@"^(?>(?<major>0|[1-9]\d*))\.(?>(?<minor>0|[1-9]\d*))(?>(?:\.(?<patch>0|[1-9]\d*))?)(?:-(?<prerelease>(?>[a-z0-9]+[\-\.]?)+))?$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.ExplicitCapture);
/*********
** Public methods
diff --git a/src/SMAPI.Web/Framework/VersionConstraint.cs b/src/SMAPI.Web/Framework/VersionConstraint.cs
index be9c0918..cffb1092 100644
--- a/src/SMAPI.Web/Framework/VersionConstraint.cs
+++ b/src/SMAPI.Web/Framework/VersionConstraint.cs
@@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Routing.Constraints;
+using StardewModdingAPI.Common;
namespace StardewModdingAPI.Web.Framework
{
@@ -10,6 +11,6 @@ namespace StardewModdingAPI.Web.Framework
*********/
/// <summary>Construct an instance.</summary>
public VersionConstraint()
- : base(@"^v(?>(?<major>0|[1-9]\d*))\.(?>(?<minor>0|[1-9]\d*))(?>(?:\.(?<patch>0|[1-9]\d*))?)(?:-(?<prerelease>(?>[a-z0-9]+[\-\.]?)+))?$") { }
+ : base(SemanticVersionImpl.Regex) { }
}
}