Skip to content

Commit a49a155

Browse files
authored
Merge pull request #694 from favicode/fix/geoip
fix GEOIP redirection causes 404 #693
2 parents 8c97f4c + 1694050 commit a49a155

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Block/GeoIp/GetAction.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* @copyright Copyright (c) 2016 Fastly, Inc. (http://www.fastly.com)
1919
* @license BSD, see LICENSE_FASTLY_CDN.txt
2020
*/
21+
2122
namespace Fastly\Cdn\Block\GeoIp;
2223

2324
use Fastly\Cdn\Model\Config;
@@ -60,13 +61,14 @@ class GetAction extends AbstractBlock
6061
* @param EncoderInterface $urlEncoder
6162
*/
6263
public function __construct(
63-
Config $config,
64-
Context $context,
65-
Response $response,
66-
Url $url,
64+
Config $config,
65+
Context $context,
66+
Response $response,
67+
Url $url,
6768
EncoderInterface $urlEncoder,
68-
array $data = []
69-
) {
69+
array $data = []
70+
)
71+
{
7072
$this->config = $config;
7173
$this->response = $response;
7274
$this->url = $url;
@@ -92,8 +94,8 @@ protected function _toHtml() // @codingStandardsIgnoreLine - required by parent
9294
$currentUrl = $this->url->getCurrentUrl();
9395
$baseUrl = $this->url->getBaseUrl();
9496
$webTypeUrl = $this->url->getBaseUrl(['_type' => Url::URL_TYPE_WEB]);
95-
96-
if (strpos($currentUrl, $baseUrl) !== false) {
97+
98+
if (strpos($currentUrl, rtrim($baseUrl, "/")) !== false) {
9799
$targetUrl = $currentUrl;
98100
} else {
99101
$targetUrl = str_replace($webTypeUrl, $baseUrl, $currentUrl);
@@ -109,7 +111,7 @@ protected function _toHtml() // @codingStandardsIgnoreLine - required by parent
109111
$this->response->setHeader("x-esi", "1");
110112
}
111113
// Due to Varnish parser limitations HTTPS ESIs are not supported so we need to turn them into HTTP URLs
112-
// This does not mean that request will go over HTTP. ESI subrequest will go out to the backend that is
114+
// This does not mean that request will go over HTTP. ESI subrequest will go out to the backend that is
113115
// currently specified so if it's HTTPS it will go over HTTPS
114116
return sprintf(
115117
'<esi:include src=\'%s\' />',

0 commit comments

Comments
 (0)