Skip to content

Commit

Permalink
Merge pull request #26048 from nextcloud/urlgenerator-cache-base-url
Browse files Browse the repository at this point in the history
cache baseurl in url generator
  • Loading branch information
rullzer authored Mar 10, 2021
2 parents a6447a5 + c048f01 commit 1efa548
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/private/URLGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
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 1efa548

Please sign in to comment.