]> source.dussan.org Git - nextcloud-server.git/commitdiff
cache baseurl in url generator 26048/head
authorRobin Appelman <robin@icewind.nl>
Wed, 10 Mar 2021 16:22:31 +0000 (17:22 +0100)
committerRobin Appelman <robin@icewind.nl>
Wed, 10 Mar 2021 16:22:31 +0000 (17:22 +0100)
Servers don't tend to change their url in the middle of a request

Signed-off-by: Robin Appelman <robin@icewind.nl>
lib/private/URLGenerator.php

index f0de31568f4d647ecdebaeb436203186219acd75..6c68f5d805f60556aa1ef76b1a12ba95a7044a66 100644 (file)
@@ -59,6 +59,8 @@ class URLGenerator implements IURLGenerator {
        private $request;
        /** @var Router */
        private $router;
+       /** @var null|string */
+       private $baseUrl = null;
 
        public function __construct(IConfig $config,
                                                                ICacheFactory $cacheFactory,
@@ -269,6 +271,9 @@ class URLGenerator implements IURLGenerator {
         * @return string base url of the current request
         */
        public function getBaseUrl(): string {
-               return $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . \OC::$WEBROOT;
+               if ($this->baseUrl === null) {
+                       $this->baseUrl = $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . \OC::$WEBROOT;
+               }
+               return $this->baseUrl;
        }
 }