Merge pull request #26048 from nextcloud/urlgenerator-cache-base-url

cache baseurl in url generator
This commit is contained in:
Roeland Jago Douma 2021-03-10 19:58:03 +01:00 committed by GitHub
commit 1efa54827c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View 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;
}
}