Skip to content

Commit

Permalink
cors: refactor loop to if (#37257)
Browse files Browse the repository at this point in the history
Signed-off-by: Adi Suissa-Peleg <[email protected]>
  • Loading branch information
adisuissa authored Nov 22, 2024
1 parent 9aad332 commit cef073e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions source/extensions/filters/http/cors/cors_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,17 +292,17 @@ bool CorsFilter::allowPrivateNetworkAccess() {
}

bool CorsFilter::shadowEnabled() {
for (const Router::CorsPolicy& policy : policies_) {
return policy.shadowEnabled();
}
return false;
// The policies_ vector is ordered from most-specific (route-entry) to the
// most-generic (virtual-host). This will return the most-specific
// shadow-enabled value (if exists).
return policies_.empty() ? false : policies_[0].get().shadowEnabled();
}

bool CorsFilter::enabled() {
for (const Router::CorsPolicy& policy : policies_) {
return policy.enabled();
}
return false;
// The policies_ vector is ordered from most-specific (route-entry) to the
// most-generic (virtual-host). This will return the most-specific enabled
// value (if exists).
return policies_.empty() ? false : policies_[0].get().enabled();
}

} // namespace Cors
Expand Down

0 comments on commit cef073e

Please sign in to comment.