Skip to content

Commit cabc41c

Browse files
committed
refactor: remove external url check
1 parent 563230e commit cabc41c

File tree

2 files changed

+1
-33
lines changed

2 files changed

+1
-33
lines changed

src/Middleware/AddHttp2ServerPush.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public function handle(Request $request, Closure $next)
3333
return $response;
3434
}
3535

36-
// use the crawler to fetch the nodes we want from the response
3736
$this->fetchLinkableNodes($response);
3837

3938
return $response;
@@ -48,20 +47,11 @@ protected function fetchLinkableNodes(Response $response)
4847
{
4948
$crawler = $this->getCrawler($response);
5049

51-
// look to see if link can have any type other than css or a font
52-
// distinguish font vs css by looking at extension, css vs eot or svg etc...
53-
54-
// include images??
55-
5650
$nodes = $crawler->filter('link, script[src]')->extract(['src', 'href']);
5751

58-
// this is giving me a listing of LOCAL urls for any links or scripts
59-
// now I just need to determine which type, make sure you account for query strings on end
6052
$headers = collect($nodes)->flatten(1)
6153
->filter()
62-
->reject(function ($url) {
63-
return $this->isExternalUrl($url);
64-
})->map(function ($url) {
54+
->map(function ($url) {
6555
return $this->buildLinkHeaderString($url);
6656
})->filter()
6757
->implode(',');
@@ -89,16 +79,6 @@ protected function getCrawler(Response $response)
8979
return $this->crawler = new Crawler($response->getContent());
9080
}
9181

92-
/**
93-
* @param $url
94-
* @return bool
95-
*/
96-
private function isExternalUrl($url)
97-
{
98-
// is this a local fully qualified url
99-
return str_contains($url, "//");
100-
}
101-
10282
/**
10383
* @param String $url
10484
* @return string

tests/AddHttp2ServerPushTest.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,6 @@ public function it_will_not_return_a_push_header_for_inline_js()
8080
$this->assertFalse($this->isServerPushResponse($response));
8181
}
8282

83-
/** @test */
84-
public function it_will_not_return_a_push_header_for_external_resources()
85-
{
86-
// TODO: check that double slash isn't OUR sites url
87-
88-
$request = new Request();
89-
90-
$response = $this->middleware->handle($request, $this->getNext('pageWithExternalAssets'));
91-
92-
$this->assertFalse($this->isServerPushResponse($response));
93-
}
94-
9583
/**
9684
* @param string $pageName
9785
*

0 commit comments

Comments
 (0)