summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-02-25 23:27:44 -0500
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-02-25 23:27:44 -0500
commit212e85489a456acca6889faff5da835cbb707080 (patch)
treec262c217f73f9fe394763ba4403c73e51e0b07f2 /src
parent0f8d183ec71ca42fdbfef08f7e1edc7f822ef040 (diff)
downloadSMAPI-212e85489a456acca6889faff5da835cbb707080.tar.gz
SMAPI-212e85489a456acca6889faff5da835cbb707080.tar.bz2
SMAPI-212e85489a456acca6889faff5da835cbb707080.zip
fix log parser not correctly parsing mod list if a mod has no author name
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Common/SemanticVersionImpl.cs5
-rw-r--r--src/SMAPI.Web/Framework/LogParsing/LogParser.cs4
2 files changed, 7 insertions, 2 deletions
diff --git a/src/SMAPI.Common/SemanticVersionImpl.cs b/src/SMAPI.Common/SemanticVersionImpl.cs
index 1c713b47..084f56a3 100644
--- a/src/SMAPI.Common/SemanticVersionImpl.cs
+++ b/src/SMAPI.Common/SemanticVersionImpl.cs
@@ -22,6 +22,9 @@ namespace StardewModdingAPI.Common
/// <summary>An optional prerelease tag.</summary>
public string Tag { get; }
+ /// <summary>A regex pattern matching a version within a larger string.</summary>
+ internal const string UnboundedVersionPattern = @"(?>(?<major>0|[1-9]\d*))\.(?>(?<minor>0|[1-9]\d*))(?>(?:\.(?<patch>0|[1-9]\d*))?)(?:-(?<prerelease>(?>[a-z0-9]+[\-\.]?)+))?";
+
/// <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>,
@@ -30,7 +33,7 @@ namespace StardewModdingAPI.Common
/// - 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);
+ internal static readonly Regex Regex = new Regex($@"^{SemanticVersionImpl.UnboundedVersionPattern}$", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase | RegexOptions.Compiled | RegexOptions.ExplicitCapture);
/*********
** Public methods
diff --git a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs
index 23a1baa4..385accf0 100644
--- a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs
+++ b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
+using StardewModdingAPI.Common;
using StardewModdingAPI.Web.Framework.LogParsing.Models;
namespace StardewModdingAPI.Web.Framework.LogParsing
@@ -29,7 +30,8 @@ namespace StardewModdingAPI.Web.Framework.LogParsing
private readonly Regex ModListStartPattern = new Regex(@"^Loaded \d+ mods:$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
/// <summary>A regex pattern matching an entry in SMAPI's mod list.</summary>
- private readonly Regex ModListEntryPattern = new Regex(@"^ (?<name>.+) (?<version>.+) by (?<author>.+) \| (?<description>.+)$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
+ /// <remarks>The author name and description are optional.</remarks>
+ private readonly Regex ModListEntryPattern = new Regex(@"^ (?<name>.+?) (?<version>" + SemanticVersionImpl.UnboundedVersionPattern + @")(?: by (?<author>[^\|]+))?(?: \| (?<description>.+))?$", RegexOptions.Compiled | RegexOptions.IgnoreCase);
/// <summary>A regex pattern matching the start of SMAPI's content pack list.</summary>
private readonly Regex ContentPackListStartPattern = new Regex(@"^Loaded \d+ content packs:$", RegexOptions.Compiled | RegexOptions.IgnoreCase);