Skip to content

Commit a9b7c84

Browse files
author
Rafael Grigorian
committed
Fixed #55
1 parent 082ce57 commit a9b7c84

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/app/code/JetRails/Cloudflare/Console/Command/AbstractCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ protected function _getDomainNames () {
3030
$stores = $this->_storeManager->getStores ();
3131
foreach ( $stores as $store ) {
3232
$domain = parse_url ( $store->getBaseUrl () ) ["host"];
33-
array_push ( $domains, $domain );
33+
preg_match ( "/([^.\s]+\.([^.\s]{3,}|[^.\s]{2}\.[^.\s]{2}|[^.\s]{2}))\b$/im", $domain, $matches );
34+
array_push ( $domains, $matches [ 1 ] );
3435
}
3536
$domains = array_unique ( $domains );
3637
sort ( $domains );
@@ -47,7 +48,8 @@ protected function _getStoreByDomain ( $domain ) {
4748
$stores = $this->_storeManager->getStores ();
4849
foreach ( $stores as $store ) {
4950
$host = parse_url ( $store->getBaseUrl () ) ["host"];
50-
if ( $host === $domain ) {
51+
preg_match ( "/([^.\s]+\.([^.\s]{3,}|[^.\s]{2}\.[^.\s]{2}|[^.\s]{2}))\b$/im", $host, $matches );
52+
if ( $matches [ 1 ] === $domain ) {
5153
return $store;
5254
}
5355
}

src/app/code/JetRails/Cloudflare/Helper/Adminhtml/Data.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function getDomainName () {
161161
}
162162
$domain = $this->_storeManager->getStore ()->getBaseUrl ();
163163
$domain = parse_url ( $domain ) ["host"];
164-
preg_match ( "/\.?([^.]+\.[^.]+)$/i", $domain, $matches );
164+
preg_match ( "/([^.\s]+\.([^.\s]{3,}|[^.\s]{2}\.[^.\s]{2}|[^.\s]{2}))\b$/im", $domain, $matches );
165165
return $matches [ 1 ];
166166
}
167167

@@ -179,7 +179,7 @@ public function getDomainNames () {
179179
$stores = $this->_storeManager->getStores ();
180180
foreach ( $stores as $store ) {
181181
$domain = parse_url ( $store->getBaseUrl () ) ["host"];
182-
preg_match ( "/\.?([^.]+\.[^.]+)$/im", $domain, $matches );
182+
preg_match ( "/([^.\s]+\.([^.\s]{3,}|[^.\s]{2}\.[^.\s]{2}|[^.\s]{2}))\b$/im", $domain, $matches );
183183
$domain = $matches [ 1 ];
184184
array_push ( $domains, $domain );
185185
}

0 commit comments

Comments
 (0)