Skip to content

Commit

Permalink
Better content-type check (updated to v5.0.5)
Browse files Browse the repository at this point in the history
Updated PR Athlon1600#37 by JClerc to have no conflicts with the base branch.
  • Loading branch information
webaddicto authored Oct 27, 2017
1 parent 42c7a5e commit 6550a67
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Plugin/ProxifyPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,16 @@ public function onCompleted(ProxyEvent $event){
$this->base_url = $event['request']->getUri();

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

$str = $response->getContent();

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

// remove JS from urls
Expand Down

0 comments on commit 6550a67

Please sign in to comment.