]> BookStack Code Mirror - bookstack/commitdiff
Fixed baseURL helper when no app url is set
authorDan Brown <redacted>
Fri, 9 Nov 2018 21:29:30 +0000 (21:29 +0000)
committerDan Brown <redacted>
Fri, 9 Nov 2018 21:29:30 +0000 (21:29 +0000)
Also cleaned variable naming to be more obvious

app/helpers.php

index aca832ea51656434c84079069ef35da4747051a0..b0886d02b9762c27383e37f5b7989014607ed03c 100644 (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;
 }
 
 /**
Morty Proxy This is a proxified and sanitized view of the page, visit original site.