public PathBasedPresetTreeExclusion(string excludedPath, TemplateTreeRoot root) { _excludedPath = excludedPath; // path that does not start with / is relative to the parent include root path if (!_excludedPath.StartsWith("/")) { _excludedPath = $"{root.Path.TrimEnd('/')}/{_excludedPath}"; } // for legacy compatibility you can exclude children by having a path exclusion end with a trailing slash // but since we add a trailing slash internally to all paths (so that we match by path e.g. /foo != /foot) // we need to know if the original string had a trailing slash and handle it as a child exclusion _implicitChildrenExclusion = _excludedPath.EndsWith("/"); // we internally add a trailing slash to the excluded path, and add a trailing slash to the incoming evaluate path // why? because otherwise using StartsWith would mean that /foo would also exclude /foot. But /foo/ and /foot/ do not match like that. _excludedPath = PathTool.EnsureTrailingSlash(_excludedPath); }