From 63fe8684c4e02f57deca53d1f530e6207da0c4da Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Mon, 4 Dec 2017 15:57:13 -0500 Subject: [PATCH] Fix js minification url --- public/js.php | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/public/js.php b/public/js.php index 88523810..305d8863 100644 --- a/public/js.php +++ b/public/js.php @@ -18,7 +18,7 @@ namespace Aviat\EasyMin; use function Amp\wait; use Amp\Artax\{Client, FormBody, Request}; -use Aviat\Ion\Json; +use Aviat\Ion\{Json, JsonException}; // Include Amp and Artax require_once('../vendor/autoload.php'); @@ -121,7 +121,7 @@ class JSMin { $request = (new Request) ->setMethod('POST') - ->setUri('http://closure-compiler.appspot.com/compile') + ->setUri('https://closure-compiler.appspot.com/compile') ->setAllHeaders([ 'Accept' => 'application/json', 'Accept-Encoding' => 'gzip', @@ -144,17 +144,25 @@ class JSMin { */ protected function checkMinifyErrors($options) { - $errorRes = $this->closureCall($options); - $errorJson = $errorRes->getBody(); - $errorObj = Json::decode($errorJson) ?: (object)[]; - - - // Show error if exists - if ( ! empty($errorObj->errors) || ! empty($errorObj->serverErrors)) + try { - $errorJson = Json::encode($errorObj, JSON_PRETTY_PRINT); - header('Content-type: application/javascript'); - echo "console.error(${errorJson});"; + $errorRes = $this->closureCall($options); + $errorJson = $errorRes->getBody(); + $errorObj = Json::decode($errorJson) ?: (object)[]; + + + // Show error if exists + if ( ! empty($errorObj->errors) || ! empty($errorObj->serverErrors)) + { + $errorJson = Json::encode($errorObj, JSON_PRETTY_PRINT); + header('Content-type: application/javascript'); + echo "console.error(${errorJson});"; + die(); + } + } + catch (JsonException $e) + { + print_r($e); die(); } }