From 7699bffb1c90e7e67e48da80cd13812bf68d1f5c Mon Sep 17 00:00:00 2001 From: Manfred Egger Date: Wed, 22 Feb 2017 09:10:12 +0100 Subject: [PATCH] Bugfix: if config.absRefPrefix is used, fullUrl returns false absolute uri. Example: config.absRefPrefix = /test/ results in http://example.com/test/test/page instead of http://example.com/test/page --- Classes/Utility/GeneralUtility.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Classes/Utility/GeneralUtility.php b/Classes/Utility/GeneralUtility.php index c157fe6..8ddebf8 100644 --- a/Classes/Utility/GeneralUtility.php +++ b/Classes/Utility/GeneralUtility.php @@ -413,19 +413,21 @@ public static function fullUrl($url, $domain = null) if ($url === '/') { $url = ''; } - - // remove first / - if (strpos($url, '/') === 0) { - $url = substr($url, 1); - } - + if ($domain !== null) { - // specified domain - $url = 'http://' . $domain . '/' . $url; + if(!preg_match('/^https?:\/\//i', $domain)) { + $domain = 'http://' . $domain; + } + $domain = rtrim($domain, '/').'/'; } else { - // domain from env - $url = Typo3GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $url; + if (strpos($url, '/') === 0) { + $domain = Typo3GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST'); + } else { + $domain = Typo3GeneralUtility::getIndpEnv('TYPO3_SITE_URL'); + } } + + $url = $domain . $url; } // Fix url stuff