/** * Get the base URL for the request. * * @param string $scheme * @param string $root * @return string */ protected function getRootUrl($scheme, $root = null) { if (is_null($root)) { if (is_null($this->cachedRoot)) { $request = $this->app->make('request'); $this->cachedRoot = rtrim($request->getSchemeAndHttpHost() . $request->getBaseUrl(), '/'); } $root = $this->cachedRoot; } $start = starts_with($root, 'http://') ? 'http://' : 'https://'; return preg_replace('~' . $start . '~', $scheme, $root, 1); }