diff --git a/composer.json b/composer.json index 0f472aa..c219a63 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": ">=5.5.9", - "illuminate/support": "~5.0.14|~5.1", + "illuminate/support": "~5.0.14|~5.1|^6.0", "guzzlehttp/guzzle": "^6.0", "symfony/psr-http-message-bridge": "^1.0" }, diff --git a/src/PrerenderMiddleware.php b/src/PrerenderMiddleware.php index 04f6ac5..6b68d37 100644 --- a/src/PrerenderMiddleware.php +++ b/src/PrerenderMiddleware.php @@ -5,11 +5,12 @@ use Closure; -use Redirect; +use GuzzleHttp\Client as Guzzle; use GuzzleHttp\Exception\RequestException; use Illuminate\Contracts\Foundation\Application; -use GuzzleHttp\Client as Guzzle; +use Illuminate\Support\Str; use Psr\Http\Message\ResponseInterface; +use Redirect; use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory; use Symfony\Component\HttpFoundation\Response; @@ -151,7 +152,7 @@ private function shouldShowPrerenderedPage($request) // prerender if a crawler is detected foreach ($this->crawlerUserAgents as $crawlerUserAgent) { - if (str_contains($userAgent, strtolower($crawlerUserAgent))) { + if (Str::contains($userAgent, strtolower($crawlerUserAgent))) { $isRequestingPrerenderedPage = true; } } @@ -196,17 +197,10 @@ private function getPrerenderedPageResponse($request) $headers['X-Prerender-Token'] = $this->prerenderToken; } - $protocol = $request->isSecure() ? 'https' : 'http'; - try { // Return the Guzzle Response - $host = $request->getHost(); - $path = $request->Path(); - // Fix "//" 404 error - if ($path == "/") { - $path = ""; - } - return $this->client->get($this->prerenderUri . '/' . urlencode($protocol.'://'.$host.'/'.$path), compact('headers')); + $uri = $request->getUri(); + return $this->client->get($this->prerenderUri . '/' . urlencode($uri), compact('headers')); } catch (RequestException $exception) { if(!$this->returnSoftHttpCodes && !empty($exception->getResponse()) && $exception->getResponse()->getStatusCode() == 404) { \App::abort(404); @@ -245,7 +239,7 @@ private function isListed($needles, $list) foreach ($list as $pattern) { foreach ($needles as $needle) { - if (str_is($pattern, $needle)) { + if (Str::is($pattern, $needle)) { return true; } }