Skip to content

Commit

Permalink
Inject the resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
tonysm committed Jan 6, 2024
1 parent e5c0741 commit a47604c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/Http/Middleware/AddLinkHeadersForPreloadedPins.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class AddLinkHeadersForPreloadedPins
{
public function __construct(private ?AssetResolver $assetsResolver = null)
public function __construct(private AssetResolver $assetsResolver = new AssetResolver())
{
}

Expand All @@ -21,9 +21,7 @@ public function __construct(private ?AssetResolver $assetsResolver = null)
public function handle($request, $next)
{
return tap($next($request), function ($response) {
$resolver = $this->assetsResolver ?? new AssetResolver();

if ($preloaded = Importmap::preloadedModulePaths($resolver)) {
if ($preloaded = Importmap::preloadedModulePaths($this->assetsResolver)) {
$response->header('Link', collect($preloaded)
->map(fn ($url) => "<{$url}>; rel=\"modulepreload\"")
->join(', '));
Expand Down

0 comments on commit a47604c

Please sign in to comment.