Skip to content

Commit

Permalink
Do not minify if the body is json
Browse files Browse the repository at this point in the history
  • Loading branch information
hailwood authored Feb 7, 2018
1 parent bed056e commit 078d000
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion code/SS_RelativeAssetsResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ public function setBody($body)

$body = str_replace('"/assets/', '"assets/', $body);
$body = str_replace('"assets/', '"/assets/', $body);

json_decode($body);
$bodyIsJson = json_last_error() === JSON_ERROR_NONE;


if (class_exists('zz\Html\HTMLMinify')) {
if (!$bodyIsJson && class_exists('zz\Html\HTMLMinify')) {
$this->body = zz\Html\HTMLMinify::minify($body, [
'doctype' => zz\Html\HTMLMinify::DOCTYPE_HTML5,
'optimizationLevel' => zz\Html\HTMLMinify::OPTIMIZATION_ADVANCED
Expand Down

0 comments on commit 078d000

Please sign in to comment.