cache baseurl in url generator
Servers don't tend to change their url in the middle of a request Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
cc48b81411
commit
ac29f27b17
|
@ -59,6 +59,8 @@ class URLGenerator implements IURLGenerator {
|
||||||
private $request;
|
private $request;
|
||||||
/** @var Router */
|
/** @var Router */
|
||||||
private $router;
|
private $router;
|
||||||
|
/** @var null|string */
|
||||||
|
private $baseUrl = null;
|
||||||
|
|
||||||
public function __construct(IConfig $config,
|
public function __construct(IConfig $config,
|
||||||
ICacheFactory $cacheFactory,
|
ICacheFactory $cacheFactory,
|
||||||
|
@ -269,6 +271,9 @@ class URLGenerator implements IURLGenerator {
|
||||||
* @return string base url of the current request
|
* @return string base url of the current request
|
||||||
*/
|
*/
|
||||||
public function getBaseUrl(): string {
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue