Skip to content

Commit

Permalink
MAGECLOUD-2556: Deploy failed when try to setup redirecting naked dom…
Browse files Browse the repository at this point in the history
…ain to www (#327)
  • Loading branch information
oshmyheliuk authored and shiftedreality committed Aug 2, 2018
1 parent 4a079d0 commit 2d3cf26
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/Test/Unit/Util/UrlManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,34 @@ public function returnedDataProvider()
],
],
],
'domain with www by default' => [
'routes' => [
'http://example.com/' => ['original_url' => 'http://www.{default}/', 'type' => 'upstream'],
'https://example.com/' => ['original_url' => 'https://www.{default}/', 'type' => 'upstream'],
'http://*.example.com/' => ['original_url' => 'http://*.{default}/', 'type' => 'upstream'],
'https://*.example.com/' => ['original_url' => 'https://*.{default}/', 'type' => 'upstream'],
'http://french.example.com/' => [
'original_url' => 'http://french.{default}/',
'type' => 'upstream',
],
'https://french.example.com/' => [
'original_url' => 'https://french.{default}/',
'type' => 'upstream',
],
],
[
'secure' => [
'' => 'https://example.com/',
'*' => 'https://*.example.com/',
'french' => 'https://french.example.com/',
],
'unsecure' => [
'' => 'http://example.com/',
'*' => 'http://*.example.com/',
'french' => 'http://french.example.com/',
],
],
],
];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Util/UrlManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private function parseRoutes(array $routes): array
}

$host = parse_url($val['original_url'], PHP_URL_HOST);
$originalUrlRegEx = sprintf('/\.?%s/', preg_quote(self::MAGIC_ROUTE));
$originalUrlRegEx = sprintf('/(www)?\.?%s/', preg_quote(self::MAGIC_ROUTE));
$originalUrl = preg_replace($originalUrlRegEx, '', $host);

if (strpos($key, self::PREFIX_UNSECURE) === 0) {
Expand Down

0 comments on commit 2d3cf26

Please sign in to comment.