1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-06 13:16:45 +02:00

feat(helpers): add getProjectUrl and improve getAbsoluteUrl and getBaseUrl

This commit is contained in:
Awilum
2022-06-23 19:46:49 +03:00
parent 4e17c8e92e
commit b68d15342e

View File

@@ -119,7 +119,7 @@ if (! function_exists('getBaseUrl')) {
$basePath = registry()->get('flextype.settings.base_path') ?? '';
if ($baseUrl != '') {
return $baseUrl . $basePath;
return strings($baseUrl . '/' . $basePath)->reduceSlashes()->trimRight('/')->toString();
}
$getAuth = static function (): string {
@@ -165,9 +165,9 @@ if (! function_exists('getBaseUrl')) {
if ($url) {
if ($isHttps) {
$url = 'https://' . $url . '/';
$url = 'https://' . $url;
} else {
$url = 'http://' . $url . '/';
$url = 'http://' . $url;
}
}
@@ -186,12 +186,29 @@ if (! function_exists('getAbsoluteUrl')) {
function getAbsoluteUrl(): string
{
$url = getBaseUrl();
$url .= '/';
$url .= $_SERVER['REQUEST_URI'] ?? '';
return $url;
}
}
if (! function_exists('getProjectUrl')) {
/**
* Get the application project url.
*
* @return string Application project url.
*/
function getProjectUrl(): string
{
$url = getBaseUrl();
$url .= '/';
$url .= PROJECT_NAME;
return $url;
}
}
if (! function_exists('getUriString')) {
/**
* Get uri string.