Skip to content

Commit

Permalink
refactor: simplify conditions in the CORS preflight validation
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasIommi committed Nov 24, 2024
1 parent 7bb04d7 commit 4d8101b
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -495,16 +495,9 @@ private MutableHttpResponse<?> handlePreflightRequest(@NonNull HttpRequest<?> re
@Nullable
private boolean validatePreflightRequest(@NonNull HttpRequest<?> request,
@NonNull CorsOriginConfiguration config) {
Optional<HttpMethod> methodToMatchOptional = validateMethodToMatch(request, config);
if (methodToMatchOptional.isEmpty()) {
return false;
}

if (!CorsUtil.isPreflightRequest(request)) {
return false;
}

if (!hasAllowedHeaders(request, config)) {
if (validateMethodToMatch(request, config).isEmpty() ||
!CorsUtil.isPreflightRequest(request) ||
!hasAllowedHeaders(request, config)) {
return false;
}

Expand Down

0 comments on commit 4d8101b

Please sign in to comment.