Skip to content

Commit

Permalink
Merge pull request #26052 from nextcloud/backport/26048/stable20
Browse files Browse the repository at this point in the history
[stable20] cache baseurl in url generator
  • Loading branch information
MorrisJobke committed Mar 17, 2021
2 parents 4f18ff9 + a1935d0 commit d3b279d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/private/URLGenerator.php
Expand Up @@ -59,6 +59,8 @@ class URLGenerator implements IURLGenerator {
private $request;
/** @var IRouter*/
private $router;
/** @var null|string */
private $baseUrl = null;

public function __construct(IConfig $config,
ICacheFactory $cacheFactory,
Expand Down Expand Up @@ -269,6 +271,9 @@ public function linkToDocs(string $key): string {
* @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;
}
}

0 comments on commit d3b279d

Please sign in to comment.