]> BookStack Code Mirror - bookstack/blobdiff - app/helpers.php
Preserve original display_name_attribute configuration values.
[bookstack] / app / helpers.php
index 9f2f74c18a82c944f0ff01ccfe2a310fd956c5f9..b0886d02b9762c27383e37f5b7989014607ed03c 100644 (file)
@@ -92,10 +92,15 @@ function baseUrl($path, $forceAppDomain = false)
     if ($isFullUrl && !$forceAppDomain) {
         return $path;
     }
+
     $path = trim($path, '/');
+    $base = rtrim(config('app.url'), '/');
 
     // Remove non-specified domain if forced and we have a domain
     if ($isFullUrl && $forceAppDomain) {
+        if (!empty($base) && strpos($path, $base) === 0) {
+            $path = trim(substr($path, strlen($base) - 1));
+        }
         $explodedPath = explode('/', $path);
         $path = implode('/', array_splice($explodedPath, 3));
     }
@@ -105,7 +110,7 @@ function baseUrl($path, $forceAppDomain = false)
         return url($path);
     }
 
-    return rtrim(config('app.url'), '/') . '/' . $path;
+    return $base . '/' . $path;
 }
 
 /**