fix: HTML::url
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Baoshuo Ren 2022-09-20 16:50:29 +08:00
parent 08624f88e0
commit 387fdf968b
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -53,8 +53,7 @@ class HTML {
$url = UOJConfig::$data['web']['blog']['protocol'].'://'.UOJConfig::$data['web']['blog']['host'].$port.'/'.blog_name_encode($username); $url = UOJConfig::$data['web']['blog']['protocol'].'://'.UOJConfig::$data['web']['blog']['host'].$port.'/'.blog_name_encode($username);
break; break;
case 3: case 3:
$port = ((UOJConfig::$data['web']['main']['protocol'] === "http" && UOJConfig::$data['web']['main']['port'] == 80) || (UOJConfig::$data['web']['main']['protocol'] === "https" && UOJConfig::$data['web']['main']['port'] == 443)) ? '' : (':'.UOJConfig::$data['web']['main']['port']); $url = HTML::url('/blog/'.blog_name_encode($username));
$url = '/blog/'.blog_name_encode($username);
break; break;
} }
$url .= $uri; $url .= $uri;
@ -69,8 +68,7 @@ class HTML {
$url = UOJConfig::$data['web']['blog']['protocol'].'://'.UOJConfig::$data['web']['blog']['host'].$port; $url = UOJConfig::$data['web']['blog']['protocol'].'://'.UOJConfig::$data['web']['blog']['host'].$port;
break; break;
case 3: case 3:
$port = ((UOJConfig::$data['web']['main']['protocol'] === "http" && UOJConfig::$data['web']['main']['port'] == 80) || (UOJConfig::$data['web']['main']['protocol'] === "https" && UOJConfig::$data['web']['main']['port'] == 443)) ? '' : (':'.UOJConfig::$data['web']['main']['port']); $url = HTML::url('/blogs');
$url = '/blogs';
break; break;
} }
return HTML::escape(rtrim($url, '/')); return HTML::escape(rtrim($url, '/'));
@ -90,17 +88,11 @@ class HTML {
$param = array_merge($param, $config['params']); $param = array_merge($param, $config['params']);
} }
// $url = UOJConfig::$data['web'][$config['location']]['protocol'].'://'.UOJConfig::$data['web'][$config['location']]['host']; $url = '//'.UOJConfig::$data['web'][$config['location']]['host'];
// if ((UOJConfig::$data['web'][$config['location']]['protocol'] === "http" && UOJConfig::$data['web'][$config['location']]['port'] == 80) || (UOJConfig::$data['web'][$config['location']]['protocol'] === "https" && UOJConfig::$data['web'][$config['location']]['port'] == 443)) {
// } else {
// $url .= ':'.UOJConfig::$data['web'][$config['location']]['port'];
// }
if ($param) { if ($param) {
$url .= $path.'?'.HTML::query_string_encode($param); $url .= $path.'?'.HTML::query_string_encode($param);
} elseif ($path != '/') {
$url .= rtrim($path, '/');
} else { } else {
$url = $path; $url .= rtrim($path, '/');
} }
return HTML::escape($url); return HTML::escape($url);
} }