Skip to content

Commit

Permalink
Merge pull request #694 from favicode/fix/geoip
Browse files Browse the repository at this point in the history
fix GEOIP redirection causes 404 #693
  • Loading branch information
vvuksan authored Apr 8, 2024
2 parents 8c97f4c + 1694050 commit a49a155
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions Block/GeoIp/GetAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
* @license BSD, see LICENSE_FASTLY_CDN.txt
*/

namespace Fastly\Cdn\Block\GeoIp;

use Fastly\Cdn\Model\Config;
Expand Down Expand Up @@ -60,13 +61,14 @@ class GetAction extends AbstractBlock
* @param EncoderInterface $urlEncoder
*/
public function __construct(
Config $config,
Context $context,
Response $response,
Url $url,
Config $config,
Context $context,
Response $response,
Url $url,
EncoderInterface $urlEncoder,
array $data = []
) {
array $data = []
)
{
$this->config = $config;
$this->response = $response;
$this->url = $url;
Expand All @@ -92,8 +94,8 @@ protected function _toHtml() // @codingStandardsIgnoreLine - required by parent
$currentUrl = $this->url->getCurrentUrl();
$baseUrl = $this->url->getBaseUrl();
$webTypeUrl = $this->url->getBaseUrl(['_type' => Url::URL_TYPE_WEB]);
if (strpos($currentUrl, $baseUrl) !== false) {

if (strpos($currentUrl, rtrim($baseUrl, "/")) !== false) {
$targetUrl = $currentUrl;
} else {
$targetUrl = str_replace($webTypeUrl, $baseUrl, $currentUrl);
Expand All @@ -109,7 +111,7 @@ protected function _toHtml() // @codingStandardsIgnoreLine - required by parent
$this->response->setHeader("x-esi", "1");
}
// Due to Varnish parser limitations HTTPS ESIs are not supported so we need to turn them into HTTP URLs
// This does not mean that request will go over HTTP. ESI subrequest will go out to the backend that is
// This does not mean that request will go over HTTP. ESI subrequest will go out to the backend that is
// currently specified so if it's HTTPS it will go over HTTPS
return sprintf(
'<esi:include src=\'%s\' />',
Expand Down

0 comments on commit a49a155

Please sign in to comment.