Skip to content

Commit 6550a67

Browse files
authored
Better content-type check (updated to v5.0.5)
Updated PR Athlon1600#37 by JClerc to have no conflicts with the base branch.
1 parent 42c7a5e commit 6550a67

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Plugin/ProxifyPlugin.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,16 @@ public function onCompleted(ProxyEvent $event){
142142
$this->base_url = $event['request']->getUri();
143143

144144
$response = $event['response'];
145-
$content_type = $response->headers->get('content-type');
145+
$content_type = strtolower(trim($response->headers->get('content-type')));
146146

147147
$str = $response->getContent();
148148

149149
// DO NOT do any proxification on .js files and text/plain content type
150-
if($content_type == 'text/javascript' || $content_type == 'application/javascript' || $content_type == 'application/x-javascript' || $content_type == 'text/plain'){
151-
return;
150+
// Support also resource like Content-Type: text/javascript;charset=UTF-8
151+
foreach(array('text/javascript', 'application/javascript', 'application/x-javascript', 'text/plain') as $type){
152+
if(strpos($content_type, $type) === 0){
153+
return;
154+
}
152155
}
153156

154157
// remove JS from urls

0 commit comments

Comments
 (0)