Skip to content

Commit e523bac

Browse files
committed
refactor: improve readability of hasNativeHeaderConflict method
1 parent 07abd76 commit e523bac

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

system/Debug/Toolbar.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -561,14 +561,12 @@ protected function hasNativeHeaderConflict(): bool
561561

562562
// Native Header Inspection
563563
foreach (headers_list() as $header) {
564-
// Content-Type is set but is NOT text/html
565-
$lowercaseHeader = strtolower($header);
564+
$lowerHeader = strtolower($header);
566565

567-
if (str_starts_with($lowercaseHeader, 'content-type:') && ! str_contains($lowercaseHeader, 'text/html')) {
568-
return true;
569-
}
570-
// File is being downloaded (Attachment)
571-
if (str_starts_with(strtolower($header), strtolower('Content-Disposition:')) && str_contains(strtolower($header), strtolower('attachment'))) {
566+
$isNonHtmlContent = str_starts_with($lowerHeader, 'content-type:') && ! str_contains($lowerHeader, 'text/html');
567+
$isAttachment = str_starts_with($lowerHeader, 'content-disposition:') && str_contains($lowerHeader, 'attachment');
568+
569+
if ($isNonHtmlContent || $isAttachment) {
572570
return true;
573571
}
574572
}

0 commit comments

Comments
 (0)