Skip to content
Snippets Groups Projects
Commit 4b9bbb9f authored by Christel Loftus's avatar Christel Loftus
Browse files

Clean identifier url

parent 6d003aac
No related branches found
No related tags found
2 merge requests!201.0.41,!14Start webhook implementation
......@@ -110,6 +110,22 @@ class OrderCreateWebhook implements ObserverInterface
private function getStoreUrl(): string
{
return $this->storeManager->getStore()->getBaseUrl();
$url = $this->storeManager->getStore()->getBaseUrl();
// Remove protocol (http:// or https://)
$host = preg_replace('#^https?://#', '', $url);
// Ensure $host is a string before using it in explode
$host = $host ?? '';
// Remove everything after the host (e.g., paths, query strings)
$host = explode('/', $host)[0];
// If the host starts with 'www.', remove it
if (strpos($host, 'www.') === 0) {
$host = substr($host, 4);
}
return $host;
}
}
......@@ -109,6 +109,22 @@ class OrderUpdateWebhook implements ObserverInterface
private function getStoreUrl(): string
{
return $this->storeManager->getStore()->getBaseUrl();
$url = $this->storeManager->getStore()->getBaseUrl();
// Remove protocol (http:// or https://)
$host = preg_replace('#^https?://#', '', $url);
// Ensure $host is a string before using it in explode
$host = $host ?? '';
// Remove everything after the host (e.g., paths, query strings)
$host = explode('/', $host)[0];
// If the host starts with 'www.', remove it
if (strpos($host, 'www.') === 0) {
$host = substr($host, 4);
}
return $host;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment