Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
cache baseurl in url generator
Servers don't tend to change their url in the middle of a request

Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 authored and backportbot[bot] committed Mar 10, 2021
commit a1935d0f74a0ab45e5496d675aa94513bb019967
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 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;
}
}