@@ -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-
9897function getHyperlink ($ text , ...$ url_components )
9998{
10099 $ text = htmlspecialchars ($ text );
0 commit comments