summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework/Clients/GenericModDownload.cs
diff options
context:
space:
mode:
authorJamie Taylor <Jamie.Taylor@pobox.com>2022-09-22 23:03:26 -0400
committerJamie Taylor <Jamie.Taylor@pobox.com>2022-10-01 21:18:50 -0400
commit6d4eed56b1d80d02db773b0cd2f372baec6b2d1b (patch)
tree3e596b6d35501f51cd557f44bdefe4170b8a17ec /src/SMAPI.Web/Framework/Clients/GenericModDownload.cs
parentc0e31d17a6d3f235c8a251e851c446e00c804cdb (diff)
downloadSMAPI-6d4eed56b1d80d02db773b0cd2f372baec6b2d1b.tar.gz
SMAPI-6d4eed56b1d80d02db773b0cd2f372baec6b2d1b.tar.bz2
SMAPI-6d4eed56b1d80d02db773b0cd2f372baec6b2d1b.zip
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.
Diffstat (limited to 'src/SMAPI.Web/Framework/Clients/GenericModDownload.cs')
-rw-r--r--src/SMAPI.Web/Framework/Clients/GenericModDownload.cs14
1 files changed, 14 insertions, 0 deletions
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
{
/// <summary>Generic metadata about a file download on a mod page.</summary>
@@ -29,5 +31,17 @@ namespace StardewModdingAPI.Web.Framework.Clients
this.Description = description;
this.Version = version;
}
+
+ /// <summary>
+ /// Return true if the subkey matches this download. A subkey matches if it appears as
+ /// a substring in the name or description.
+ /// </summary>
+ /// <param name="subkey">the subkey</param>
+ /// <returns><c>true</c> if <paramref name="subkey"/> matches this download, otherwise <c>false</c></returns>
+ /// <exception cref="System.NotImplementedException"></exception>
+ public bool MatchesSubkey(string subkey) {
+ return this.Name.Contains(subkey, StringComparison.OrdinalIgnoreCase) == true
+ || this.Description?.Contains(subkey, StringComparison.OrdinalIgnoreCase) == true;
+ }
}
}