From 546cac0142fedc6c1ec109bba10100f869e22bf6 Mon Sep 17 00:00:00 2001
From: BillyGriffiths <billy.griffiths@gmail.com>
Date: Mon, 13 Feb 2023 15:49:17 +0200
Subject: [PATCH] better way of getting the baseURL

---
 Model/Carrier/CustomShipping.php | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/Model/Carrier/CustomShipping.php b/Model/Carrier/CustomShipping.php
index 421e3df..5a8c8a4 100644
--- a/Model/Carrier/CustomShipping.php
+++ b/Model/Carrier/CustomShipping.php
@@ -188,11 +188,8 @@ class CustomShipping extends AbstractCarrierOnline implements CarrierInterface
      */
     public function getBaseUrl(): string
     {
-        $storeBase = $this->_storeManager->getStore()->getBaseUrl();
-        // Strip slashes and http:// or https:// and wwww. from the url leaving just "example.com"
-        $storeBase = preg_replace('/(http:\/\/|https:\/\/|www\.)/', '', $storeBase);
-        $storeBase = preg_replace('/(\/)/', '', $storeBase);
-        return $storeBase;
+        $storeBaseUrl = $this->_storeManager->getStore()->getBaseUrl();
+        return parse_url($storeBaseUrl)["host"];
     }
 
     /**
-- 
GitLab