Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust content type condition to evaluate to true when no content is displayed #15603

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ public ValueTask<bool> EvaluateAsync(Condition condition)
private ValueTask<bool> EvaluateAsync(ContentTypeCondition condition)
{
var operatorComparer = _operatorResolver.GetOperatorComparer(condition.Operation);

// If no content types are considered, use the empty string as the value to compare against,
// since we still want comparisons such as "Does Not Equal", "Does Not Start With", etc. to evaluate to true in this case.
if (_contentTypes.Count == 0)
{
return ValueTask.FromResult(operatorComparer.Compare(condition.Operation, string.Empty, condition.Value));
}

foreach (var contentType in _contentTypes)
{
if (operatorComparer.Compare(condition.Operation, contentType, condition.Value))
Expand Down
Loading