diff --git a/src/Middleware/AddHttp2ServerPush.php b/src/Middleware/AddHttp2ServerPush.php index 167d1c6..ac3fd26 100644 --- a/src/Middleware/AddHttp2ServerPush.php +++ b/src/Middleware/AddHttp2ServerPush.php @@ -109,7 +109,7 @@ private function buildLinkHeaderString($url) '.TIFF' => 'image', ]; - $type = collect($linkTypeMap)->first(function ($extension) use ($url) { + $type = collect($linkTypeMap)->first(function ($type, $extension) use ($url) { return str_contains(strtoupper($url), $extension); }); diff --git a/tests/AddHttp2ServerPushTest.php b/tests/AddHttp2ServerPushTest.php index 99502c8..c15eed1 100644 --- a/tests/AddHttp2ServerPushTest.php +++ b/tests/AddHttp2ServerPushTest.php @@ -49,7 +49,7 @@ public function it_will_return_a_js_link_header_for_js() } /** @test */ - public function it_will_return_a_image_link_header_for_images() + public function it_will_return_an_image_link_header_for_images() { $request = new Request(); @@ -57,7 +57,7 @@ public function it_will_return_a_image_link_header_for_images() $this->assertTrue($this->isServerPushResponse($response)); $this->assertStringEndsWith("as=image", $response->headers->get('link')); - $this->assertCount(6, explode(",", $response->headers)); + $this->assertCount(6, explode(",", $response->headers->get('link'))); } /** @test */ @@ -80,7 +80,7 @@ public function it_will_return_correct_push_headers_for_multiple_assets() $this->assertTrue($this->isServerPushResponse($response)); $this->assertTrue(str_contains($response->headers, 'style')); $this->assertTrue(str_contains($response->headers, 'script')); - $this->assertCount(2, explode(",", $response->headers)); + $this->assertCount(2, explode(",", $response->headers->get('link'))); } /** @test */