From 6d4eed56b1d80d02db773b0cd2f372baec6b2d1b Mon Sep 17 00:00:00 2001 From: Jamie Taylor Date: Thu, 22 Sep 2022 23:03:26 -0400 Subject: refactor UpdateKey parsing, move responsibility for subkey matching UpdateKey parsing now allows multiple : and @ inside the update key, splitting on the first occurence of each Subkey matching is moved into IModDownload / GenericModDownload, in preparation for some Mod Sites using something less error-prone than substring matching. --- src/SMAPI.Web/Framework/Clients/GenericModDownload.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/SMAPI.Web/Framework/Clients') diff --git a/src/SMAPI.Web/Framework/Clients/GenericModDownload.cs b/src/SMAPI.Web/Framework/Clients/GenericModDownload.cs index 548f17c3..b37e5cda 100644 --- a/src/SMAPI.Web/Framework/Clients/GenericModDownload.cs +++ b/src/SMAPI.Web/Framework/Clients/GenericModDownload.cs @@ -1,3 +1,5 @@ +using System; + namespace StardewModdingAPI.Web.Framework.Clients { /// Generic metadata about a file download on a mod page. @@ -29,5 +31,17 @@ namespace StardewModdingAPI.Web.Framework.Clients this.Description = description; this.Version = version; } + + /// + /// Return true if the subkey matches this download. A subkey matches if it appears as + /// a substring in the name or description. + /// + /// the subkey + /// true if matches this download, otherwise false + /// + public bool MatchesSubkey(string subkey) { + return this.Name.Contains(subkey, StringComparison.OrdinalIgnoreCase) == true + || this.Description?.Contains(subkey, StringComparison.OrdinalIgnoreCase) == true; + } } } -- cgit