Skip to content

Commit 2d3cf26

Browse files
oshmyheliukshiftedreality
authored andcommitted
MAGECLOUD-2556: Deploy failed when try to setup redirecting naked domain to www (#327)
1 parent 4a079d0 commit 2d3cf26

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/Test/Unit/Util/UrlManagerTest.php

+28
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,34 @@ public function returnedDataProvider()
317317
],
318318
],
319319
],
320+
'domain with www by default' => [
321+
'routes' => [
322+
'http://example.com/' => ['original_url' => 'http://www.{default}/', 'type' => 'upstream'],
323+
'https://example.com/' => ['original_url' => 'https://www.{default}/', 'type' => 'upstream'],
324+
'http://*.example.com/' => ['original_url' => 'http://*.{default}/', 'type' => 'upstream'],
325+
'https://*.example.com/' => ['original_url' => 'https://*.{default}/', 'type' => 'upstream'],
326+
'http://french.example.com/' => [
327+
'original_url' => 'http://french.{default}/',
328+
'type' => 'upstream',
329+
],
330+
'https://french.example.com/' => [
331+
'original_url' => 'https://french.{default}/',
332+
'type' => 'upstream',
333+
],
334+
],
335+
[
336+
'secure' => [
337+
'' => 'https://example.com/',
338+
'*' => 'https://*.example.com/',
339+
'french' => 'https://french.example.com/',
340+
],
341+
'unsecure' => [
342+
'' => 'http://example.com/',
343+
'*' => 'http://*.example.com/',
344+
'french' => 'http://french.example.com/',
345+
],
346+
],
347+
],
320348
];
321349
}
322350

src/Util/UrlManager.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private function parseRoutes(array $routes): array
6161
}
6262

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

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

0 commit comments

Comments
 (0)