File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ public function handle(Request $request, Closure $next): Response
1717 /** @var \Symfony\Component\HttpFoundation\Response $response */
1818 $ response = $ next ($ request );
1919
20- if ($ this ->shouldInject ($ response-> getContent () )) {
20+ if ($ this ->shouldInject ($ response )) {
2121 $ originalView = $ response ->original ?? null ;
2222 $ injectedContent = $ this ->injectScript ($ response ->getContent ());
2323 $ response ->setContent ($ injectedContent );
@@ -30,8 +30,13 @@ public function handle(Request $request, Closure $next): Response
3030 return $ response ;
3131 }
3232
33- private function shouldInject (string $ content ): bool
33+ private function shouldInject (Response $ response ): bool
3434 {
35+ if (str_contains ($ response ->headers ->get ('content-type ' ), 'html ' ) === false ) {
36+ return false ;
37+ }
38+
39+ $ content = $ response ->getContent ();
3540 // Check if it's HTML
3641 if (! str_contains ($ content , '<html ' ) && ! str_contains ($ content , '<head ' )) {
3742 return false ;
You can’t perform that action at this time.
0 commit comments