summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI.Web/Framework/VersionConstraint.cs
blob: be9c0918918f54243bfd80d5a75a8fb185daef1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
using Microsoft.AspNetCore.Routing.Constraints;

namespace StardewModdingAPI.Web.Framework
{
    /// <summary>Constrains a route value to a valid semantic version.</summary>
    internal class VersionConstraint : RegexRouteConstraint
    {
        /*********
        ** Public methods
        *********/
        /// <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]+[\-\.]?)+))?$") { }
    }
}