Skip to content
Snippets Groups Projects
Commit ac29f27b authored by Robin Appelman's avatar Robin Appelman Committed by backportbot[bot]
Browse files

cache baseurl in url generator


Servers don't tend to change their url in the middle of a request

Signed-off-by: default avatarRobin Appelman <robin@icewind.nl>
parent cc48b814
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment