Servers don't tend to change their url in the middle of a request
Signed-off-by: Robin Appelman <robin@icewind.nl>
private $request;
/** @var Router */
private $router;
+ /** @var null|string */
+ private $baseUrl = null;
public function __construct(IConfig $config,
ICacheFactory $cacheFactory,
* @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;
}
}