Fixed baseURL helper when no app url is set

Also cleaned variable naming to be more obvious
This commit is contained in:
Dan Brown 2018-11-09 21:29:30 +00:00
parent e3230f8f21
commit 038b2418f7
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9

View File

@ -94,12 +94,12 @@ function baseUrl($path, $forceAppDomain = false)
}
$path = trim($path, '/');
$trimBase = rtrim(config('app.url'), '/');
$base = rtrim(config('app.url'), '/');
// Remove non-specified domain if forced and we have a domain
if ($isFullUrl && $forceAppDomain) {
if (strpos($path, $trimBase) === 0) {
$path = trim(substr($path, strlen($trimBase) - 1));
if (!empty($base) && strpos($path, $base) === 0) {
$path = trim(substr($path, strlen($base) - 1));
}
$explodedPath = explode('/', $path);
$path = implode('/', array_splice($explodedPath, 3));
@ -110,7 +110,7 @@ function baseUrl($path, $forceAppDomain = false)
return url($path);
}
return $trimBase . '/' . $path;
return $base . '/' . $path;
}
/**