Skip to content

Commit cbb56e0

Browse files
committed
refactor
1 parent b6460e6 commit cbb56e0

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

resources/lib/utils.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,23 @@ function pathNormalize(string $path)
7777
return preg_replace("#/+#", "/", $path);
7878
}
7979

80-
function pathJoin(...$path_components)
80+
function getURL(...$relative_url_components)
8181
{
82-
$path = join("/", $path_components);
82+
$url_components = array_merge(
83+
[CONFIG["site"]["url"], CONFIG["site"]["prefix"]],
84+
$relative_url_components,
85+
);
86+
$url = join("/", $url_components);
8387
// if URL starts with a "scheme" like "https://", do not try to alter the slashes in the scheme
84-
if (preg_match("#^\w+://#", $path)) {
88+
if (preg_match("#^\w+://#", $url)) {
8589
$matches = [];
86-
preg_match("#(^\w+://)(.*)#", $path, $matches);
90+
preg_match("#(^\w+://)(.*)#", $url, $matches);
8791
return $matches[1] . pathNormalize($matches[2]);
8892
} else {
89-
return pathNormalize($path);
93+
return pathNormalize($url);
9094
}
9195
}
9296

93-
function getURL(...$url_components)
94-
{
95-
return pathJoin(CONFIG["site"]["url"], CONFIG["site"]["prefix"], ...$url_components);
96-
}
97-
9897
function getHyperlink($text, ...$url_components)
9998
{
10099
$text = htmlspecialchars($text);

0 commit comments

Comments
 (0)