summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-11-11 21:22:52 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-11-11 21:22:52 -0500
commitad2dcc28791eb8026335646474fb2e0766fcc51b (patch)
tree42a043a4878664500436dadd49f7c524a30f1d69 /src/SMAPI/Framework
parent2bccdd97370b958187b0ad99437e4ca85ec5ae1f (diff)
downloadSMAPI-ad2dcc28791eb8026335646474fb2e0766fcc51b.tar.gz
SMAPI-ad2dcc28791eb8026335646474fb2e0766fcc51b.tar.bz2
SMAPI-ad2dcc28791eb8026335646474fb2e0766fcc51b.zip
expand code comments for clarity
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r--src/SMAPI/Framework/Content/AssetName.cs12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/SMAPI/Framework/Content/AssetName.cs b/src/SMAPI/Framework/Content/AssetName.cs
index a1c6a5da..8355f9ec 100644
--- a/src/SMAPI/Framework/Content/AssetName.cs
+++ b/src/SMAPI/Framework/Content/AssetName.cs
@@ -162,10 +162,14 @@ namespace StardewModdingAPI.Framework.Content
if (prefixHasMore)
return false;
- // match if subfolder paths are fine (e.g. prefix 'Data/Events' with target 'Data/Events/Beach')
- // special case if the original prefix ended with a '/' - subfolder checking pushes forward one, to check the Remainder instead of Current
- // which is necessarily nonzero in this block.
- return allowSubfolder || (pathSeparators.Contains(trimmedPrefix[^1]) && curParts.Remainder.Length == 0);
+ // match: every segment in the prefix matched and subfolders are allowed (e.g. prefix 'Data/Events' with target 'Data/Events/Beach')
+ if (allowSubfolder)
+ return true;
+
+ // Special case: the prefix ends with a path separator, but subfolders aren't allowed. This case
+ // matches if there's no further path separator in the asset name *after* the current separator.
+ // For example, the prefix 'A/B/' matches 'A/B/C' but not 'A/B/C/D'.
+ return pathSeparators.Contains(trimmedPrefix[^1]) && curParts.Remainder.Length == 0;
}
// previous segments matched exactly and both reached the end