diff options
author | Robin Appelman <robin@icewind.nl> | 2021-03-10 17:22:31 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2021-03-10 19:38:30 +0000 |
commit | ac29f27b1790e12b5ce50a6953714879b8f79630 (patch) | |
tree | 2c07c5319f5d31411f40ebb35cbc4887b7e200b5 | |
parent | cc48b81411104e7e8b206dc64ae23f169aae4e58 (diff) | |
download | nextcloud-server-ac29f27b1790e12b5ce50a6953714879b8f79630.tar.gz nextcloud-server-ac29f27b1790e12b5ce50a6953714879b8f79630.zip |
cache baseurl in url generator
Servers don't tend to change their url in the middle of a request
Signed-off-by: Robin Appelman <robin@icewind.nl>
-rw-r--r-- | lib/private/URLGenerator.php | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/private/URLGenerator.php b/lib/private/URLGenerator.php index f0de31568f4..6c68f5d805f 100644 --- a/lib/private/URLGenerator.php +++ b/lib/private/URLGenerator.php @@ -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; } } |