fix(legacy): do not rely on undefined SERVER_NAME (#2031)
This commit is contained in:
parent
631a7956ea
commit
45c283504e
3 changed files with 9 additions and 34 deletions
|
@ -516,23 +516,7 @@ SQL;
|
|||
*/
|
||||
public function getFileUrl()
|
||||
{
|
||||
$protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https';
|
||||
|
||||
$serverName = $_SERVER['SERVER_NAME'];
|
||||
$serverPort = $_SERVER['SERVER_PORT'];
|
||||
$subDir = Config::getBasePath();
|
||||
|
||||
if ($protocol === 'https' && $serverPort == 80) {
|
||||
$serverPort = 443;
|
||||
}
|
||||
|
||||
if ($subDir[0] === '/') {
|
||||
$subDir = substr($subDir, 1, strlen($subDir) - 1);
|
||||
}
|
||||
|
||||
$baseUrl = "{$protocol}://{$serverName}:{$serverPort}/{$subDir}";
|
||||
|
||||
return $this->getRelativeFileUrl($baseUrl);
|
||||
return $this->getRelativeFileUrl(Config::getPublicUrl());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue