Skip to content

Commit

Permalink
Fix unpacking
Browse files Browse the repository at this point in the history
  • Loading branch information
tonysm committed Jan 12, 2024
1 parent 60a50f3 commit ef715d9
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/Http/Middleware/AddLinkHeaderForPreloadedAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ public function handle($request, $next)
{
return tap($next($request), function ($response) {
if (count($assets = $this->manifest->assetsForPreloading()) > 0) {
$response->header('Link', trim(implode(', ', array_filter([
$response->headers->get('Link', null),
...collect($assets)
->map(fn ($attributes, $asset) => implode('; ', [
"<$asset>",
...collect(array_merge(['rel' => 'preload', 'as' => 'style'], $attributes))
->map(fn ($value, $key) => "{$key}={$value}")
->all(),
]))
->all(),
]))));
$response->header('Link', trim(implode(', ', array_filter(array_merge(
[$response->headers->get('Link', null)],
collect($assets)->map(fn ($attributes, $asset) => implode('; ', array_merge(
["<$asset>"],
collect(array_merge(['rel' => 'preload', 'as' => 'style'], $attributes))
->map(fn ($value, $key) => "{$key}={$value}")
->all(),
)))->all(),
)))));
}
});
}
Expand Down

0 comments on commit ef715d9

Please sign in to comment.