Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev' into issue/OCC-137
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahelsaig committed Aug 8, 2023
2 parents 1eded62 + 66138db commit 746fabc
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,15 @@ public ResourceFilter When(Func<HttpContext, Task<bool>> filterAsync)
}

/// <summary>
/// Adds a filter that matches the given <paramref name="path"/> to the list of <see cref="ResourceFilters"/>.
/// Adds a filter that matches any of the provided <paramref name="paths"/> to the list of
/// <see cref="ResourceFilters"/>.
/// </summary>
public ResourceFilter WhenPath(string path) =>
When(context => context.Request.Path.Value?.Trim('/').EqualsOrdinalIgnoreCase(path.Trim('/')) == true);
public ResourceFilter WhenPath(params string[] paths)
{
var trimmedPaths = paths.Select(path => path.Trim('/'));
return When(context =>
trimmedPaths.Contains(context.Request.Path.Value?.Trim('/'), StringComparer.OrdinalIgnoreCase));
}

/// <summary>
/// Adds a filter that matches the path of the homepage (<c>"/"</c>) to the list of <see cref="ResourceFilters"/>.
Expand Down

0 comments on commit 746fabc

Please sign in to comment.