aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/URLGenerator.php
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2021-03-10 17:22:31 +0100
committerRobin Appelman <robin@icewind.nl>2021-03-10 17:22:31 +0100
commitc048f0100f1e8347a05d1c9b064ba9a74b973999 (patch)
tree0cf74b9e11902795392149e8f82f3517aba16403 /lib/private/URLGenerator.php
parent62929cc646134fbd409cfb4eacb7039d15763b96 (diff)
downloadnextcloud-server-c048f0100f1e8347a05d1c9b064ba9a74b973999.tar.gz
nextcloud-server-c048f0100f1e8347a05d1c9b064ba9a74b973999.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>
Diffstat (limited to 'lib/private/URLGenerator.php')
-rw-r--r--lib/private/URLGenerator.php7
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;
}
}